コード例 #1
0
 /**
  * @test
  */
 public function it_returns_a_redirect_response_to_the_destination_with_a_jwt_as_url_fragment()
 {
     $userId = new StringLiteral('id-1');
     $accessToken = new AccessToken($userId->toNative(), new TokenCredentials('token', 'secret'));
     $destination = new Uri('http://bar.com/sub/directory?query=value');
     $userClaims = new UserClaims($userId, new StringLiteral('foo'), new EmailAddress('*****@*****.**'));
     $jwt = new Jwt(['alg' => 'mocked'], $userClaims->toArray(), new Signature('gibberish'), ['headers', 'body', 'gibberish']);
     $expectedDestination = 'http://bar.com/sub/directory?query=value&jwt=headers.body.gibberish';
     $this->userService->expects($this->once())->method('getUserClaims')->with($accessToken)->willReturn($userClaims);
     $this->encoder->expects($this->once())->method('encode')->with($userClaims->toArray())->willReturn($jwt);
     $response = $this->callbackHandler->handle($accessToken, $destination);
     /* @var RedirectResponse $response */
     $this->assertInstanceOf(RedirectResponse::class, $response);
     $this->assertEquals($expectedDestination, $response->getTargetUrl());
 }
コード例 #2
0
 /**
  * @test
  */
 public function it_can_have_an_empty_email_address_by_default()
 {
     $claims = new UserClaims(new StringLiteral('id-1'), new StringLiteral('foo'));
     $expected = ['uid' => 'id-1', 'nick' => 'foo', 'email' => ''];
     $this->assertEquals($expected, $claims->toArray());
 }