Example #1
0
 public function testCreateCredentials()
 {
     $this->jobList->expects($this->once())->method('add')->with('OCA\\UpdateNotification\\ResetTokenBackgroundJob');
     $this->secureRandom->expects($this->once())->method('generate')->with(64)->willReturn('MyGeneratedToken');
     $this->config->expects($this->once())->method('setSystemValue')->with('updater.secret');
     $this->timeFactory->expects($this->once())->method('getTime')->willReturn(12345);
     $this->config->expects($this->once())->method('setAppValue')->with('core', 'updater.secret.created', 12345);
     $expected = new DataResponse('MyGeneratedToken');
     $this->assertEquals($expected, $this->adminController->createCredentials());
 }
Example #2
0
 public function testGetIdWithoutModUnique()
 {
     $lowRandomSource = $this->getMockBuilder('\\OCP\\Security\\ISecureRandom')->disableOriginalConstructor()->getMock();
     $lowRandomSource->expects($this->once())->method('generate')->with('20')->will($this->returnValue('GeneratedByOwnCloudItself'));
     $this->secureRandom->expects($this->once())->method('getLowStrengthGenerator')->will($this->returnValue($lowRandomSource));
     $request = new Request([], $this->secureRandom, $this->getMock('\\OCP\\Security\\ICrypto'), $this->config, $this->stream);
     $this->assertSame('GeneratedByOwnCloudItself', $request->getId());
 }
 public function testGenerateTokenWithDefault()
 {
     $this->random->expects($this->once())->method('generate')->with(32)->willReturn('12345678901234567890123456789012');
     $this->assertSame('12345678901234567890123456789012', $this->csrfTokenGenerator->generateToken(32));
 }
Example #4
0
 public function testGetIdWithoutModUnique()
 {
     $this->secureRandom->expects($this->once())->method('generate')->with('20')->will($this->returnValue('GeneratedByOwnCloudItself'));
     $request = new Request([], $this->secureRandom, $this->config, $this->csrfTokenManager, $this->stream);
     $this->assertSame('GeneratedByOwnCloudItself', $request->getId());
 }