1
1
<?php
2
2
3
-
4
3
use Authing \Mgmt \ManagementClient ;
5
4
use Authing \Mgmt \UsersManagementClient ;
6
5
use Authing \Types \CreateUserInput ;
@@ -13,32 +12,39 @@ class UsersManagementClientTest extends TestCase
13
12
* @var UsersManagementClient
14
13
*/
15
14
private $ client ;
15
+ private $ _testConfig ;
16
16
17
- private function randomString () {
17
+ private function randomString ()
18
+ {
18
19
return rand () . '' ;
19
20
}
20
21
21
22
public function setUp (): void
22
23
{
23
- $ management = new ManagementClient ("59f86b4832eb28071bdd9214 " , "4b880fff06b080f154ee48c9e689a541 " );
24
- $ management ->setHost ("http://localhost:3000 " );
24
+ $ moduleName = str_replace ('ClientTest ' , '' , __CLASS__ );
25
+ $ manageConfig = (object ) TestConfig::getConfig ('Management ' );
26
+ $ this ->_testConfig = (object ) TestConfig::getConfig ($ moduleName );
27
+ $ management = new ManagementClient ($ manageConfig ->userPoolId , $ manageConfig ->userPoolSercet );
25
28
$ management ->requestToken ();
26
29
$ this ->client = $ management ->users ();
27
30
}
28
31
29
- public function testPaginate () {
32
+ public function testPaginate ()
33
+ {
30
34
$ users = $ this ->client ->paginate ();
31
35
$ this ->assertEquals (true , $ users ->totalCount > 0 );
32
36
}
33
37
34
- public function testCreate () {
38
+ public function testCreate ()
39
+ {
35
40
$ email = $ this ->randomString () . '@gmail.com ' ;
36
41
$ password = '123456 ' ;
37
42
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
38
43
$ this ->assertEquals ($ email , $ user ->email );
39
44
}
40
45
41
- public function testUpdate () {
46
+ public function testUpdate ()
47
+ {
42
48
$ email = $ this ->randomString () . '@gmail.com ' ;
43
49
$ password = '123456 ' ;
44
50
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
@@ -47,7 +53,8 @@ public function testUpdate() {
47
53
$ this ->assertEquals ("nickname " , $ user ->nickname );
48
54
}
49
55
50
- public function testDetail () {
56
+ public function testDetail ()
57
+ {
51
58
$ email = $ this ->randomString () . '@gmail.com ' ;
52
59
$ password = '123456 ' ;
53
60
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
@@ -56,7 +63,8 @@ public function testDetail() {
56
63
$ this ->assertEquals ($ email , $ user ->email );
57
64
}
58
65
59
- public function testDelete () {
66
+ public function testDelete ()
67
+ {
60
68
$ email = $ this ->randomString () . '@gmail.com ' ;
61
69
$ password = '123456 ' ;
62
70
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
@@ -65,7 +73,8 @@ public function testDelete() {
65
73
$ this ->assertEquals (200 , $ message ->code );
66
74
}
67
75
68
- public function testDeleteMany () {
76
+ public function testDeleteMany ()
77
+ {
69
78
$ email = $ this ->randomString () . '@gmail.com ' ;
70
79
$ password = '123456 ' ;
71
80
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
@@ -74,7 +83,8 @@ public function testDeleteMany() {
74
83
$ this ->assertEquals (200 , $ message ->code );
75
84
}
76
85
77
- public function testRefreshToken () {
86
+ public function testRefreshToken ()
87
+ {
78
88
$ email = $ this ->randomString () . '@gmail.com ' ;
79
89
$ password = '123456 ' ;
80
90
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
@@ -83,7 +93,8 @@ public function testRefreshToken() {
83
93
$ this ->assertNotEquals (null , $ message ->token );
84
94
}
85
95
86
- public function testCheckLoginStatus () {
96
+ public function testCheckLoginStatus ()
97
+ {
87
98
$ email = $ this ->randomString () . '@gmail.com ' ;
88
99
$ password = '123456 ' ;
89
100
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
@@ -92,7 +103,8 @@ public function testCheckLoginStatus() {
92
103
$ this ->assertEquals (200 , $ message ->code );
93
104
}
94
105
95
- public function testListRoles () {
106
+ public function testListRoles ()
107
+ {
96
108
$ email = $ this ->randomString () . '@gmail.com ' ;
97
109
$ password = '123456 ' ;
98
110
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
@@ -101,12 +113,41 @@ public function testListRoles() {
101
113
$ this ->assertEquals (true , $ roles ->totalCount == 0 );
102
114
}
103
115
104
- public function testListPolicies () {
116
+ public function testListPolicies ()
117
+ {
105
118
$ email = $ this ->randomString () . '@gmail.com ' ;
106
119
$ password = '123456 ' ;
107
120
$ user = $ this ->client ->create ((new CreateUserInput ())->withEmail ($ email )->withPassword ($ password ));
108
121
109
122
$ policies = $ this ->client ->listPolicies ($ user ->id );
110
123
$ this ->assertEquals (true , $ policies ->totalCount == 0 );
111
124
}
112
- }
125
+
126
+ public function testGetUdfValue ()
127
+ {
128
+ $ userId = $ this ->_testConfig ->userId ;
129
+ $ data = $ this ->client ->getUdfValue ($ userId );
130
+ parent ::assertNotEmpty ($ data );
131
+ }
132
+
133
+ public function testListArchivedUsers ()
134
+ {
135
+ $ data = $ this ->client ->listArchivedUsers ();
136
+ parent ::assertNotEmpty ($ data );
137
+ }
138
+
139
+ public function testListDepartment ()
140
+ {
141
+ $ userId = $ this ->_testConfig ->userId ;
142
+ $ data = $ this ->client ->listDepartment ($ userId );
143
+ parent ::assertNotEmpty ($ data );
144
+ }
145
+
146
+ public function testSetUdvBatch ()
147
+ {
148
+ $ data = $ this ->client ->setUdfValueBatch ();
149
+ parent ::assertNotEmpty ($ data );
150
+ }
151
+
152
+
153
+ }
0 commit comments