Example #1
0
 protected function setUp()
 {
     parent::setUp();
     $this->timeFactory = $this->getMock('\\OCP\\AppFramework\\Utility\\ITimeFactory');
     $this->timeFactory->expects($this->any())->method('getTime')->will($this->returnValue(10000));
     $this->tokenProvider = $this->getMock('\\OC\\Authentication\\Token\\IProvider');
     $this->config = $this->getMock('\\OCP\\IConfig');
 }
 public function testRunWithExpiredToken()
 {
     $this->timeFactory->expects($this->at(0))->method('getTime')->willReturn(1455131633);
     $this->timeFactory->expects($this->at(1))->method('getTime')->willReturn(1455045234);
     $this->config->expects($this->once())->method('getAppValue')->with('core', 'updater.secret.created', 1455045234);
     $this->config->expects($this->once())->method('deleteSystemValue')->with('updater.secret');
     $this->invokePrivate($this->resetTokenBackgroundJob, 'run', ['']);
 }
Example #3
0
 public function setUp()
 {
     $this->currentTime = time();
     $this->timeFactory = $this->getMock('\\OCP\\AppFramework\\Utility\\ITimeFactory');
     $this->timeFactory->expects($this->any())->method('getTime')->will($this->returnCallback(function () {
         return $this->currentTime;
     }));
     parent::setUp();
 }
Example #4
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 #5
0
 public function testGetNextSkipNonExisting()
 {
     $job = new TestJob();
     $this->createTempJob('\\OC\\Non\\Existing\\Class', 1, 0, 12345);
     $this->createTempJob(get_class($job), 2, 0, 12346);
     $this->timeFactory->expects($this->atLeastOnce())->method('getTime')->willReturn(123456789);
     $nextJob = $this->instance->getNext();
     $this->assertEquals(get_class($job), get_class($nextJob));
     $this->assertEquals(2, $nextJob->getArgument());
 }
 public function testSetFingerPrint()
 {
     $this->timeFactory->expects($this->once())->method('getTime')->willReturn(42);
     $this->config->expects($this->once())->method('setSystemValue')->with('data-fingerprint', md5(42));
     self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
 }