File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 77
88class Session extends \PleskX \Api \Operator
99{
10+ /**
11+ * @param string $username
12+ * @param string $userIp
13+ *
14+ * @return string
15+ */
16+ public function create ($ username , $ userIp )
17+ {
18+ $ packet = $ this ->_client ->getPacket ();
19+ $ creator = $ packet ->addChild ('server ' )->addChild ('create_session ' );
20+
21+ $ creator ->addChild ('login ' , $ username );
22+ $ loginData = $ creator ->addChild ('data ' );
23+
24+ $ loginData ->addChild ('user_ip ' , base64_encode ($ userIp ));
25+ $ loginData ->addChild ('source_server ' , '' );
26+
27+ $ response = $ this ->_client ->request ($ packet );
28+
29+ return (string ) $ response ->id ;
30+ }
31+
1032 /**
1133 * @return Struct\Info[]
1234 */
Original file line number Diff line number Diff line change 55
66class SessionTest extends TestCase
77{
8+
9+ public function testCreate ()
10+ {
11+ $ sessionToken = static ::$ _client ->session ()->create ('admin ' , '127.0.0.1 ' );
12+
13+ $ this ->assertIsString ($ sessionToken );
14+ $ this ->assertGreaterThan (10 , strlen ($ sessionToken ));
15+ }
16+
817 public function testGet ()
918 {
1019 $ sessionId = static ::$ _client ->server ()->createSession ('admin ' , '127.0.0.1 ' );
You can’t perform that action at this time.
0 commit comments