/** * @test */ public function handleReturnResponse() { $token = new Token(); $token->setUser('admin'); $token->digest = 'admin'; $token->nonce = 'admin'; $token->created = '2010-12-12 20:00:00'; $response = new Response(); $this->authenticationManager->expects($this->once())->method('authenticate')->with($token)->will($this->returnValue($response)); $this->responseEvent->expects($this->once())->method('setResponse')->with($response); $this->request->headers->add(array('X-WSSE' => 'UsernameToken Username="******", PasswordDigest="admin", Nonce="admin", Created="2010-12-12 20:00:00"')); $listener = new Listener($this->securityContext, $this->authenticationManager); $listener->handle($this->responseEvent); }
/** * @test */ public function getCredentials() { $token = new Token(); $this->assertEquals('', $token->getCredentials()); }
/** * @test * @depends validateDigestWithNonceDirExpectedException * @depends validateDigestWithNonceDir * @depends validateDigestWithoutNonceDir * @depends validateDigestExpireTime */ public function authenticate() { $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); $user->expects($this->once())->method('getPassword')->will($this->returnValue('test')); $user->expects($this->once())->method('getRoles')->will($this->returnValue(array())); $this->userProvider->expects($this->once())->method('loadUserByUsername')->will($this->returnValue($user)); $expected = new Token(); $expected->setUser($user); $expected->setAuthenticated(true); $time = date('Y-m-d H:i:s'); $digest = base64_encode(sha1(base64_decode(base64_encode('test')) . $time . 'test', true)); //$digest, base64_encode('test'), $time, 'test', true), $token = new Token(); $token->digest = $digest; $token->nonce = base64_encode('test'); $token->created = $time; $provider = new ProviderTestSimple($this->userProvider); $result = $provider->authenticate($token); $this->assertEquals($expected, $result); }