37
37
*/
38
38
class Client extends BaseTestCase {
39
39
40
+ /**
41
+ * @tags testInitSession
42
+ */
40
43
public function testInitSession () {
41
44
$ client = $ this ->newTestedInstance (GLPI_URL );
42
45
43
46
// Test invalid credentials
44
47
$ this ->exception (function () use ($ client ) {
45
48
$ client ->initSessionByCredentials ('glpi ' , 'bad password ' );
46
- })->isIdenticalTo ( $ this -> exception );
49
+ })->hasMessage ( ' Cannot connect to api ' );
47
50
48
51
// Test valid credentials
49
52
$ success = $ client ->initSessionByCredentials ('glpi ' , 'glpi ' );
50
53
$ this ->boolean ($ success )->isTrue ();
51
54
52
55
// Test invalid credentials for user token
53
- $ this ->exception (function () use ($ client ){
56
+ $ this ->exception (function () use ($ client ) {
54
57
$ client ->initSessionByUserToken ('loremIpsum ' );
55
- })->isIdenticalTo ($ this ->exception );
56
- }
57
-
58
- /*public function testComputer() {
59
- $client = $this->newTestedInstance(GLPI_URL);
60
- $this->boolean($client->initSessionByCredentials('glpi', 'glpi'))->isTrue();
58
+ })->hasMessage ('Cannot connect to api ' );
61
59
62
- $response = $client->computer('post', ['name' => 'computer 0001']);
63
- $this->object($response)->isInstanceOf(\Psr\Http\Message\ResponseInterface::class);
64
- }*/
60
+ // TODO: Test valid credentials for user token
61
+ /*$response = $client->initSessionByUserToken('loremIpsum');
62
+ $this->boolean($success)->isTrue();*/
63
+ }
65
64
65
+ /**
66
+ * @tags testGetFullSession
67
+ */
66
68
public function testGetFullSession () {
67
69
$ this ->loginSuperAdmin ();
68
70
$ response = $ this ->client ->getFullSession ();
69
71
$ this ->assertJsonResponse ($ response );
72
+ }
73
+
74
+ /**
75
+ * @tags testKillSession
76
+ */
77
+ public function testKillSession () {
78
+ $ this ->loginSuperAdmin ();
79
+ $ client = $ this ->client ;
80
+ $ response = $ client ->killSession ();
81
+ $ this ->boolean ($ response )->isTrue ();
82
+
83
+ // Test invalid kill session
84
+ $ this ->exception (function () use ($ client ) {
85
+ $ client ->killSession ();
86
+ })->hasMessage ('session_token seems invalid ' );
87
+ }
70
88
89
+
90
+ /**
91
+ * @tags testGetGlpiConfig
92
+ */
93
+ public function testGetGlpiConfig () {
94
+ $ this ->loginSuperAdmin ();
95
+ $ response = $ this ->client ->getGlpiConfig ();
96
+ $ this ->assertJsonResponse ($ response );
97
+ $ arrayOfStdClass = json_decode ($ response ['body ' ]);
98
+ $ this ->boolean (property_exists ($ arrayOfStdClass , 'cfg_glpi ' ))->isTrue ();
71
99
}
72
100
73
101
}
0 commit comments