/
test_connection.py
63 lines (47 loc) · 3.29 KB
/
test_connection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
from nose.tools import eq_, ok_
from mock import MagicMock
import pyps4
CRED = '0000000000000000000000000000000000000000000000000000000000000000'
class TestConnection(object):
def test_send_hello_request(self):
mock = MagicMock()
conn = pyps4.Connection('10.10.10.10')
conn._send_msg = mock
conn._send_hello_request()
conn._send_msg.assert_called_with(
b'\x1c\x00\x00\x00pcco\x00\x00\x02\x00\x00\x00'
+ b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
# def test_send_handshake_request(self):
# mock = MagicMock()
#
# conn = pyps4.Connection('10.10.10.10')
# conn._send_msg = mock
# conn._send_handshake_request(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')
# conn._send_msg.assert_called_with(
# b'\x1c\x00\x00\x00pcco\x00\x00\x02\x00\x00\x00'
# + b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
def test_send_login_request(self):
mock = MagicMock()
conn = pyps4.Connection('10.10.10.10', credential=CRED)
conn._send_msg = mock
conn._send_login_request()
conn._send_msg.assert_called_with(
b'\x80\x01\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x000000000000000000000000000000000000000000000000000000000000000000PlayStation\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x004.4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00PS4 Waker\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
encrypted=True)
def test_send_standby_request(self):
mock = MagicMock()
conn = pyps4.Connection('10.10.10.10', credential=CRED)
conn._send_msg = mock
conn._send_standby_request()
conn._send_msg.assert_called_with(
b'\x08\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
encrypted=True)
def test_send_boot_request(self):
mock = MagicMock()
conn = pyps4.Connection('10.10.10.10', credential=CRED)
conn._send_msg = mock
conn._send_boot_request(title_id='abcdef')
conn._send_msg.assert_called_with(
b'\x18\x00\x00\x00\n\x00\x00\x00abcdef\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
encrypted=True)