Skip to content

Commit

Permalink
fix: adjust test for static method invocation
Browse files Browse the repository at this point in the history
Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
  • Loading branch information
ernolf committed Aug 8, 2024
1 parent bf4f8e7 commit 24e485a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/Unit/Controller/SettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,25 @@ public function testCreateSecret() {
->method('getCloudId')
->willReturn('user@instance.com');

$secret = 'newsecret';
$algorithm = ITotp::getAlgorithmById(1);
$digits = 6;
$period = ITotp::DEFAULT_PERIOD;
$this->totp->expects($this->once())
->method('createSecret')
->with($user, null, 1, 6, 30)
->willReturn('newsecret');

// Mock the default algorithm and digits
$this->totp->expects($this->once())
->method('getDefaultAlgorithm')
->willReturn(1);
$this->totp->expects($this->once())
->method('getDefaultDigits')
->willReturn(6);

$issuer = rawurlencode($this->defaults->getName());
$qrUrl = "otpauth://totp/{$issuer}:user%40instance.com?secret=$secret&issuer=$issuer&algorithm=SHA1&digits=$digits&period=$period&image=";
$qrUrl = "otpauth://totp/{$issuer}:user%40instance.com?secret=newsecret&issuer=$issuer&algorithm=SHA1&digits=6&period=30&image=";

$expected = new JSONResponse([
'state' => ITotp::STATE_CREATED,
'secret' => $secret,
'secret' => 'newsecret',
'qrUrl' => $qrUrl
]);

Expand Down

0 comments on commit 24e485a

Please sign in to comment.