-
Notifications
You must be signed in to change notification settings - Fork 45
/
test_meshnet_invite.py
187 lines (107 loc) · 5.92 KB
/
test_meshnet_invite.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import pytest
import sh
from lib import login, meshnet, ssh
ssh_client = ssh.Ssh("qa-peer", "root", "root")
def setup_module(module): # noqa: ARG001
meshnet.TestUtils.setup_module(ssh_client)
def teardown_module(module): # noqa: ARG001
meshnet.TestUtils.teardown_module(ssh_client)
def setup_function(function): # noqa: ARG001
meshnet.TestUtils.setup_function(ssh_client)
def teardown_function(function): # noqa: ARG001
meshnet.TestUtils.teardown_function(ssh_client)
def test_invite_send():
assert "Meshnet invitation to '[email protected]' was sent." in meshnet.send_meshnet_invite("[email protected]")
assert "[email protected]" in sh.nordvpn.meshnet.invite.list()
def test_invite_send_repeated():
meshnet.send_meshnet_invite("[email protected]")
with pytest.raises(sh.ErrorReturnCode_1) as ex:
meshnet.send_meshnet_invite("[email protected]")
assert "Meshnet invitation for '[email protected]' already exists." in str(ex.value)
def test_invite_send_own_email():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
meshnet.send_meshnet_invite(login.get_credentials("default").email)
assert "Email should belong to a different user." in str(ex.value)
def test_invite_send_not_an_email():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
meshnet.send_meshnet_invite("test")
assert "Invalid email 'test'." in str(ex.value)
@pytest.mark.skip(reason="A different error message is expected - LVPN-262")
def test_invite_send_long_email():
# A long email address containing more than 256 characters is created
email = "test" * 65 + "@test.com"
with pytest.raises(sh.ErrorReturnCode_1) as ex:
meshnet.send_meshnet_invite(email)
assert "It's not you, it's us. We're having trouble with our servers. If the issue persists, please contact our customer support." not in str(ex.value)
@pytest.mark.skip(reason="A different error message is expected - LVPN-262")
def test_invite_send_email_special_character():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
meshnet.send_meshnet_invite("\[email protected]")
assert "It's not you, it's us. We're having trouble with our servers. If the issue persists, please contact our customer support." not in str(ex.value)
def test_invite_revoke():
meshnet.send_meshnet_invite("[email protected]")
assert "Meshnet invitation to '[email protected]' was revoked." in sh.nordvpn.meshnet.invite.revoke("[email protected]")
assert "[email protected]" not in sh.nordvpn.meshnet.invite.list()
def test_invite_revoke_repeated():
meshnet.send_meshnet_invite("[email protected]")
sh.nordvpn.meshnet.invite.revoke("[email protected]")
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.revoke("[email protected]")
assert "No invitation from '[email protected]' was found." in str(ex.value)
def test_invite_revoke_non_existent():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.revoke("[email protected]")
assert "No invitation from '[email protected]' was found." in str(ex.value)
def test_invite_revoke_non_existent_long_email():
email = "test" * 65 + "@test.com"
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.revoke(email)
assert f"No invitation from '{email}' was found." in str(ex.value)
def test_invite_revoke_non_existent_special_character():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.revoke("\[email protected]")
assert "No invitation from '\[email protected]' was found." in str(ex.value)
def test_invite_deny():
meshnet.remove_all_peers()
meshnet.remove_all_peers_in_peer(ssh_client)
meshnet.revoke_all_invites()
meshnet.revoke_all_invites_in_peer(ssh_client)
meshnet.send_meshnet_invite(login.get_credentials("qa-peer").email)
email = login.get_credentials("default").email
assert email in ssh_client.exec_command("nordvpn meshnet invite list")
assert f"Meshnet invitation from '{email}' was denied." in meshnet.deny_meshnet_invite(ssh_client)
def test_invite_deny_non_existent():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.deny("[email protected]")
assert "No invitation from '[email protected]' was found." in str(ex.value)
def test_invite_deny_non_existent_long_email():
email = "test" * 65 + "@test.com"
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.deny(email)
assert f"No invitation from '{email}' was found." in str(ex.value)
def test_invite_deny_non_existent_special_character():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.deny("\[email protected]")
assert "No invitation from '\[email protected]' was found." in str(ex.value)
def test_invite_accept():
meshnet.remove_all_peers()
meshnet.remove_all_peers_in_peer(ssh_client)
meshnet.revoke_all_invites()
meshnet.revoke_all_invites_in_peer(ssh_client)
meshnet.send_meshnet_invite(login.get_credentials("qa-peer").email)
email = login.get_credentials("default").email
assert email in ssh_client.exec_command("nordvpn meshnet invite list")
assert f"Meshnet invitation from '{email}' was accepted." in meshnet.accept_meshnet_invite(ssh_client)
def test_invite_accept_non_existent():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.accept("[email protected]")
assert "No invitation from '[email protected]' was found." in str(ex.value)
def test_invite_accept_non_existent_long_email():
email = "test" * 65 + "@test.com"
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.accept(email)
assert f"No invitation from '{email}' was found." in str(ex.value)
def test_invite_accept_non_existent_special_character():
with pytest.raises(sh.ErrorReturnCode_1) as ex:
sh.nordvpn.meshnet.invite.accept("\[email protected]")
assert "No invitation from '\[email protected]' was found." in str(ex.value)