You are here

public function UrlBuildersTest::testThatBasicAuthorizeLinkIsBuiltCorrectly in Auth0 Single Sign On 8.2

File

vendor/auth0/auth0-php/tests/API/Authentication/UrlBuildersTest.php, line 10

Class

UrlBuildersTest

Namespace

Auth0\Tests\API\Authentication

Code

public function testThatBasicAuthorizeLinkIsBuiltCorrectly() {
  $api = new Authentication('test-domain.auth0.com', '__test_client_id__');
  $authorize_url = $api
    ->get_authorize_link('code', 'https://example.com/cb');
  $authorize_url_parts = parse_url($authorize_url);
  $this
    ->assertEquals('https', $authorize_url_parts['scheme']);
  $this
    ->assertEquals('test-domain.auth0.com', $authorize_url_parts['host']);
  $this
    ->assertEquals('/authorize', $authorize_url_parts['path']);
  $authorize_url_query = explode('&', $authorize_url_parts['query']);
  $this
    ->assertContains('redirect_uri=https%3A%2F%2Fexample.com%2Fcb', $authorize_url_query);
  $this
    ->assertContains('response_type=code', $authorize_url_query);
  $this
    ->assertContains('client_id=__test_client_id__', $authorize_url_query);
  $this
    ->assertNotContains('connection=', $authorize_url_parts['query']);
  $this
    ->assertNotContains('state=', $authorize_url_parts['query']);

  // Telemetry should not be added to any browser URLs.
  $this
    ->assertNotContains('auth0Client=', $authorize_url_parts['query']);
}