Пример #1
0
 /**
  * tests the server responding to a cmd=lock when the account doesn't exist
  */
 public function testRespondsToLockUnknownAccount()
 {
     $this->validator->expects($this->once())->method('validateServer')->with($this->equalTo(array('ver' => '1', 'nut' => 'newNut', 'tif' => '4', 'qry' => 'sqrl?nut=newNut', 'sfn' => 'Example Server')), $this->equalTo('newNut'), $this->equalTo("1"))->will($this->returnValue(true));
     $this->validator->expects($this->once())->method('validateNut')->with($this->equalTo('newNut'), $this->equalTo('validIdentityKey'))->will($this->returnValue(\Trianglman\Sqrl\SqrlValidateInterface::VALID_NUT));
     $this->validator->expects($this->once())->method('validateSignature')->with($this->equalTo($this->base64UrlEncode("ver=1\r\ncmd=lock\r\nidk=" . $this->base64UrlEncode('validIdentityKey')) . $this->base64UrlEncode("ver=1\r\nnut=newNut\r\ntif=4\r\nqry=sqrl?nut=newNut\r\nsfn=Example Server")), $this->equalTo('validIdentityKey'), $this->equalTo('valid signature'))->will($this->returnValue(true));
     $this->validator->expects($this->once())->method('nutIPMatches')->with($this->equalTo('newNut'), $this->equalTo('192.168.0.5'))->will($this->returnValue(true));
     $this->storage->expects($this->once())->method('checkIdentityKey')->with($this->equalTo('validIdentityKey'))->will($this->returnValue(\Trianglman\Sqrl\SqrlStoreInterface::IDENTITY_UNKNOWN));
     $this->storage->expects($this->never())->method('lockIdentityKey');
     $this->storage->expects($this->never())->method('endSession');
     $this->generator->expects($this->once())->method('getNonce')->with($this->equalTo(0xc4), $this->equalTo('validIdentityKey'), $this->equalTo('newNut'))->will($this->returnValue('newerNut'));
     $this->generator->expects($this->once())->method('generateQry')->will($this->returnValue('sqrl?nut=newerNut'));
     $this->handler->parseRequest(array('nut' => 'newNut'), array('server' => $this->base64UrlEncode("ver=1\r\nnut=newNut\r\ntif=4\r\nqry=sqrl?nut=newNut\r\nsfn=Example Server"), 'client' => $this->base64UrlEncode("ver=1\r\ncmd=lock\r\nidk=" . $this->base64UrlEncode('validIdentityKey')), 'ids' => $this->base64UrlEncode('valid signature')), array('REMOTE_ADDR' => '192.168.0.5', 'HTTPS' => '1'));
     $this->assertEquals($this->base64UrlEncode("ver=1\r\nnut=newerNut\r\ntif=C4\r\nqry=sqrl?nut=newerNut\r\nsfn=Example Server"), $this->handler->getResponseMessage());
 }