Skip to content

Commit bf675cc

Browse files
committed
:octocat: allow creating secrets for Steam guard
1 parent e106cec commit bf675cc

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/Authenticators/SteamGuard.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ public function getSecret():string{
6464
return Base64::encode($this->secret);
6565
}
6666

67-
/**
68-
* @inheritDoc
69-
* @codeCoverageIgnore
70-
*/
71-
public function createSecret(int|null $length = null):string{
72-
throw new RuntimeException('Not implemented');
73-
}
74-
7567
/**
7668
* @inheritDoc
7769
*/

tests/Authenticators/SteamGuardTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use function date;
2020
use function dechex;
2121
use function is_int;
22+
use function strlen;
2223
use const PHP_INT_SIZE;
2324

2425
/**
@@ -53,19 +54,26 @@ public function testSetGetSecret():void{
5354
}
5455

5556
public function testCreateSecretDefaultLength():void{
56-
$this::markTestSkipped('N/A');
57+
$this::assertSame(
58+
$this->options->secret_length,
59+
strlen(Base64::decode($this->authenticatorInterface->createSecret()))
60+
);
5761
}
5862

5963
public function testCreateSecretWithLength():void{
60-
$this::markTestSkipped('N/A');
64+
65+
for($secretLength = 16; $secretLength <= 512; $secretLength += 8){
66+
$secret = Base64::decode($this->authenticatorInterface->createSecret($secretLength));
67+
68+
$this::assertSame($secretLength, strlen($secret));
69+
}
70+
6171
}
6272

6373
public function testCreateSecretCheckCharacterSet():void{
64-
$this::markTestSkipped('N/A');
65-
}
74+
$secret = $this->authenticatorInterface->createSecret(32);
6675

67-
public function testCreateSecretException():void{
68-
$this::markTestSkipped('N/A');
76+
$this::assertMatchesRegularExpression('#^['.Base64::CHARSET.']+$#', $secret);
6977
}
7078

7179
/**

0 commit comments

Comments
 (0)