Пример #1
0
 public function testNonceDoesntEverMatch()
 {
     $this->assertNotEmpty(Crypto::nonce());
     $i = 30;
     while ($i--) {
         $this->assertNotEquals(Crypto::nonce(), Crypto::nonce());
     }
 }
Пример #2
0
 public function testPostEmailReturnsErrorOnUnmatchableEmailAndNinjaName()
 {
     $req = Request::create('/password/post_email');
     $req->setMethod('POST');
     $req->request->set('email', 'unmatchable@' . Crypto::nonce() . 'com');
     $req->request->set('ninja_name', 'nomatch' . Crypto::nonce());
     RequestWrapper::inject($req);
     $controller = new PasswordController();
     $response = $controller->postEmail($this->m_dependencies);
     $this->assertInstanceOf(RedirectResponse::class, $response);
     $expected = 'unable to find a matching account';
     $this->assertTrue(stripos($response->getTargetUrl(), rawurlencode($expected)) !== false, 'Url Redirection for [' . $response->getTargetUrl() . '] did not contain expected error string of [' . $expected . ']');
 }
Пример #3
0
 /**
  * Generate a full password reset request for an account
  *
  * @param Account $account
  * @return PasswordResetRequest
  */
 public static function generate(Account $account, $nonce = null)
 {
     $nonce = $nonce !== null ? $nonce : Crypto::nonce();
     return self::create(['_account_id' => $account->id(), 'nonce' => $nonce]);
 }