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+ * @param string $sourceServer
14+ *
15+ * @return string
16+ */
17+ public function create ($ username , $ userIp , $ sourceServer = '' )
18+ {
19+ $ packet = $ this ->_client ->getPacket ();
20+ $ creator = $ packet ->addChild ('server ' )->addChild ('create_session ' );
21+
22+ $ creator ->addChild ('login ' , $ username );
23+ $ loginData = $ creator ->addChild ('data ' );
24+
25+ $ loginData ->addChild ('user_ip ' , base64_encode ($ userIp ));
26+ $ loginData ->addChild ('source_server ' , base64_encode ($ sourceServer ));
27+
28+ $ response = $ this ->_client ->request ($ packet );
29+
30+ return (string ) $ response ->id ;
31+ }
32+
1033 /**
1134 * @return Struct\Info[]
1235 */
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+ }
15+
816 public function testGet ()
917 {
1018 $ sessionId = static ::$ _client ->server ()->createSession ('admin ' , '127.0.0.1 ' );
You can’t perform that action at this time.
0 commit comments