public function testRestrictsUserIfInvalidCredentials()
 {
     $username = '******';
     $password = '******';
     $request = new AuthenticationRequest($username, $password);
     $this->server->SetRequest($request);
     $this->authentication->expects($this->once())->method('Validate')->with($this->equalTo($username), $this->equalTo($password))->will($this->returnValue(false));
     $this->service->Authenticate($this->server);
     $expectedResponse = AuthenticationResponse::Failed();
     $this->assertEquals($expectedResponse, $this->server->_LastResponse);
 }
 /**
  * @name Authenticate
  * @description Authenticates an existing Booked Scheduler user
  * @request AuthenticationRequest
  * @response AuthenticationResponse
  * @return void
  */
 public function Authenticate()
 {
     /** @var $request AuthenticationRequest */
     $request = $this->server->GetRequest();
     $username = $request->username;
     $password = $request->password;
     Log::Debug('WebService Authenticate for user %s', $username);
     $isValid = $this->authentication->Validate($username, $password);
     if ($isValid) {
         Log::Debug('WebService Authenticate, user %s was authenticated', $username);
         $session = $this->authentication->Login($username);
         Log::Debug('SessionToken=%s', $session->SessionToken);
         $this->server->WriteResponse(AuthenticationResponse::Success($this->server, $session));
     } else {
         Log::Debug('WebService Authenticate, user %s was not authenticated', $username);
         $this->server->WriteResponse(AuthenticationResponse::Failed());
     }
 }