You are here

public function ResourceServersTest::testCreate in Auth0 Single Sign On 8.2

Test creating a Resource Server.

Return value

void

Throws

CoreException Thrown if the identifier parameter or data field is empty or is not a string.

\Exception Thrown by the HTTP client when there is a problem with the API call.

File

vendor/auth0/auth0-php/tests/API/Management/ResourceServersTest.php, line 81

Class

ResourceServersTest
Class ResourceServersTest.

Namespace

Auth0\Tests\API\Management

Code

public function testCreate() {
  $create_data = [
    'name' => 'TEST_PHP_SDK_CREATE_' . uniqid(),
    'token_lifetime' => rand(10000, 20000),
    'signing_alg' => 'HS256',
    // Only add a single scope so we can update it later.
    'scopes' => [
      self::$scopes[0],
    ],
  ];
  $response = self::$api
    ->create(self::$serverIdentifier, $create_data);
  usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
  $this
    ->assertNotEmpty($response);
  $this
    ->assertNotEmpty($response['id']);
  $this
    ->assertEquals(self::$serverIdentifier, $response['identifier']);
  $this
    ->assertEquals($create_data['name'], $response['name']);
  $this
    ->assertEquals($create_data['token_lifetime'], $response['token_lifetime']);
  $this
    ->assertEquals($create_data['signing_alg'], $response['signing_alg']);
  $this
    ->assertEquals($create_data['scopes'], $response['scopes']);
}