918-git-images-111dconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacion
Last change
on this file since 240a4dc was
5a54cec,
checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago
|
#915 Test malformed payload for POST /wol
This test covers requests that do not contain 1 of the parameters in their
payloads.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | import requests |
---|
2 | import unittest |
---|
3 | |
---|
4 | class TestPostWolMethods(unittest.TestCase): |
---|
5 | |
---|
6 | def setUp(self): |
---|
7 | self.url = 'http://localhost:8888/wol' |
---|
8 | self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'} |
---|
9 | self.json = { 'type' : 'broadcast', 'clients' : [ { 'addr' : '192.168.2.1', |
---|
10 | 'mac' : '00AABBCCDD01' } ] } |
---|
11 | |
---|
12 | def test_post(self): |
---|
13 | returned = requests.post(self.url, headers=self.headers, json=self.json) |
---|
14 | self.assertEqual(returned.status_code, 200) |
---|
15 | |
---|
16 | def test_no_payload(self): |
---|
17 | returned = requests.post(self.url, headers=self.headers, json=None) |
---|
18 | self.assertEqual(returned.status_code, 400) |
---|
19 | |
---|
20 | def test_malformed_payload(self): |
---|
21 | for parameter in self.json: |
---|
22 | malformed_payload = self.json.copy() |
---|
23 | malformed_payload.pop(parameter) |
---|
24 | returned = requests.post(self.url, |
---|
25 | headers=self.headers, |
---|
26 | json=malformed_payload) |
---|
27 | self.assertEqual(returned.status_code, 400) |
---|
28 | |
---|
29 | def test_get(self): |
---|
30 | returned = requests.get(self.url, headers=self.headers) |
---|
31 | self.assertEqual(returned.status_code, 405) |
---|
32 | |
---|
33 | if __name__ == '__main__': |
---|
34 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.