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 7
7
8
8
class Session extends \PleskX \Api \Operator
9
9
{
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
+
10
32
/**
11
33
* @return Struct\Info[]
12
34
*/
Original file line number Diff line number Diff line change 5
5
6
6
class SessionTest extends TestCase
7
7
{
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
+
8
17
public function testGet ()
9
18
{
10
19
$ sessionId = static ::$ _client ->server ()->createSession ('admin ' , '127.0.0.1 ' );
You can’t perform that action at this time.
0 commit comments