File tree Expand file tree Collapse file tree 4 files changed +52
-2
lines changed Expand file tree Collapse file tree 4 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace Authwave ;
3
3
4
+ use Gt \Http \Uri ;
5
+ use Psr \Http \Message \UriInterface ;
6
+
4
7
class Authenticator {
8
+ private Cipher $ cipher ;
9
+ private string $ hostname ;
10
+
11
+ public function __construct (Token $ token , string $ hostname ) {
12
+ $ this ->cipher = $ token ->generateCipher ();
13
+ $ this ->hostname = $ hostname ;
14
+ }
5
15
16
+ public function getAuthUri ():UriInterface {
17
+ return (new Uri ())
18
+ ->withScheme ("https " )
19
+ ->withHost ($ this ->hostname );
20
+ }
6
21
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Authwave ;
3
+
4
+ class Cipher {
5
+
6
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Authwave ;
3
+
4
+ class Token {
5
+ private string $ key ;
6
+ private string $ tokenValue ;
7
+
8
+ public function __construct (string $ key ) {
9
+ $ this ->key = $ key ;
10
+ $ this ->tokenValue = random_bytes (16 );
11
+ }
12
+
13
+ public function generateCipher ():Cipher {
14
+
15
+ }
16
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace Authwave \Test ;
3
3
4
+ use Authwave \Authenticator ;
5
+ use Authwave \Cipher ;
6
+ use Authwave \Token ;
4
7
use PHPUnit \Framework \TestCase ;
5
8
6
9
class AuthenticatorTest extends TestCase {
7
- public function testOnePlusOne () {
8
- self ::assertEquals (2 , 1 + 1 );
10
+ public function testGetAuthUriHostname () {
11
+ $ cipher = self ::createMock (Cipher::class);
12
+ $ token = self ::createMock (Token::class);
13
+ $ token ->method ("generateCipher " )
14
+ ->willReturn ($ cipher );
15
+
16
+ $ sut = new Authenticator ($ token , "example.com " );
17
+ $ authUri = $ sut ->getAuthUri ();
18
+ self ::assertStringStartsWith (
19
+ "https://example.com " ,
20
+ $ authUri
21
+ );
9
22
}
10
23
}
You can’t perform that action at this time.
0 commit comments