@@ -38,93 +38,100 @@ public function tearDown()
38
38
unset($ this ->clientModelRepository , $ this ->repository );
39
39
}
40
40
41
- public function test_can_get_client_for_auth_code_grant ()
41
+ public function test_can_get_client ()
42
42
{
43
- $ client = $ this ->repository ->getClientEntity (1 , ' authorization_code ' , ' secret ' , true );
43
+ $ client = $ this ->repository ->getClientEntity (1 );
44
44
45
45
$ this ->assertInstanceOf (Client::class, $ client );
46
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'authorization_code ' , 'wrong-secret ' , true ));
47
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'client_credentials ' , 'wrong-secret ' , true ));
46
+ $ this ->assertEquals ('1 ' , $ client ->getIdentifier ());
47
+ $ this ->assertEquals ('Client ' , $ client ->getName ());
48
+ $ this ->assertEquals (['http://localhost ' ], $ client ->getRedirectUri ());
49
+ $ this ->assertTrue ($ client ->isConfidential ());
48
50
}
49
51
50
- public function test_can_get_client_for_client_credentials_grant ()
52
+ public function test_can_validate_client_for_auth_code_grant ()
53
+ {
54
+ $ this ->assertTrue ($ this ->repository ->validateClient (1 , 'secret ' , 'authorization_code ' ));
55
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'wrong-secret ' , 'authorization_code ' ));
56
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'wrong-secret ' , 'client_credentials ' ));
57
+ }
58
+
59
+ public function test_can_validate_client_for_client_credentials_grant ()
51
60
{
52
61
$ client = $ this ->clientModelRepository ->findActive (1 );
53
62
$ client ->personal_access_client = true ;
54
63
55
- $ this ->assertInstanceOf (
56
- Client::class,
57
- $ this ->repository ->getClientEntity (1 , 'client_credentials ' , 'secret ' , true )
58
- );
59
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'authorization_code ' , 'secret ' , true ));
64
+ $ this ->assertTrue ($ this ->repository ->validateClient (1 , 'secret ' , 'client_credentials ' ));
65
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'wrong-secret ' , 'client_credentials ' ));
66
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'secret ' , 'authorization_code ' ));
60
67
}
61
68
62
69
public function test_password_grant_is_permitted ()
63
70
{
64
71
$ client = $ this ->clientModelRepository ->findActive (1 );
65
72
$ client ->password_client = true ;
66
73
67
- $ this ->assertInstanceOf (Client::class, $ this ->repository ->getClientEntity (1 , 'password ' , 'secret ' ));
74
+ $ this ->assertTrue ( $ this ->repository ->validateClient (1 , 'secret ' , 'password ' ));
68
75
}
69
76
70
77
public function test_password_grant_is_prevented ()
71
78
{
72
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'password ' , 'secret ' ));
79
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'secret ' , 'password ' ));
73
80
}
74
81
75
82
public function test_authorization_code_grant_is_permitted ()
76
83
{
77
- $ this ->assertInstanceOf (Client::class, $ this ->repository ->getClientEntity (1 , 'authorization_code ' , 'secret ' ));
84
+ $ this ->assertTrue ( $ this ->repository ->validateClient (1 , 'secret ' , 'authorization_code ' ));
78
85
}
79
86
80
87
public function test_authorization_code_grant_is_prevented ()
81
88
{
82
89
$ client = $ this ->clientModelRepository ->findActive (1 );
83
90
$ client ->password_client = true ;
84
91
85
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'authorization_code ' , 'secret ' ));
92
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'secret ' , 'authorization_code ' ));
86
93
}
87
94
88
95
public function test_personal_access_grant_is_permitted ()
89
96
{
90
97
$ client = $ this ->clientModelRepository ->findActive (1 );
91
98
$ client ->personal_access_client = true ;
92
99
93
- $ this ->assertInstanceOf (Client::class, $ this ->repository ->getClientEntity (1 , 'personal_access ' , 'secret ' ));
100
+ $ this ->assertTrue ( $ this ->repository ->validateClient (1 , 'secret ' , 'personal_access ' ));
94
101
}
95
102
96
103
public function test_personal_access_grant_is_prevented ()
97
104
{
98
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'personal_access ' , 'secret ' ));
105
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'secret ' , 'personal_access ' ));
99
106
}
100
107
101
108
public function test_client_credentials_grant_is_permitted ()
102
109
{
103
- $ this ->assertInstanceOf (Client::class, $ this ->repository ->getClientEntity (1 , 'client_credentials ' , 'secret ' ));
110
+ $ this ->assertTrue ( $ this ->repository ->validateClient (1 , 'secret ' , 'client_credentials ' ));
104
111
}
105
112
106
113
public function test_client_credentials_grant_is_prevented ()
107
114
{
108
115
$ client = $ this ->clientModelRepository ->findActive (1 );
109
116
$ client ->secret = null ;
110
117
111
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'client_credentials ' , 'secret ' ));
118
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'secret ' , 'client_credentials ' ));
112
119
}
113
120
114
121
public function test_grant_types_allows_request ()
115
122
{
116
123
$ client = $ this ->clientModelRepository ->findActive (1 );
117
124
$ client ->grant_types = ['client_credentials ' ];
118
125
119
- $ this ->assertInstanceOf (Client::class, $ this ->repository ->getClientEntity (1 , 'client_credentials ' , 'secret ' ));
126
+ $ this ->assertTrue ( $ this ->repository ->validateClient (1 , 'secret ' , 'client_credentials ' ));
120
127
}
121
128
122
129
public function test_grant_types_disallows_request ()
123
130
{
124
131
$ client = $ this ->clientModelRepository ->findActive (1 );
125
132
$ client ->grant_types = ['client_credentials ' ];
126
133
127
- $ this ->assertNull ($ this ->repository ->getClientEntity (1 , 'authorization_code ' , 'secret ' ));
134
+ $ this ->assertFalse ($ this ->repository ->validateClient (1 , 'secret ' , 'authorization_code ' ));
128
135
}
129
136
}
130
137
0 commit comments