close
Warning:
Failed to sync with repository "ogBrowser-Git": (1366, "Incorrect string value: '\\xF0\\x9F\\x93\\xA6 I...' for column 'message' at row 1"); repository information may be out of date. Look in the Trac log for more information including mitigation strategies.
Last change
on this file was
abd2b91,
checked in by OpenGnSys Support Team <soporte-og@…>, 6 years ago
|
#915 Test malformed payload for POST commands
This patch includes tests for the remaining REST API commands:
POST /shell/output
POST /session
POST /poweroff
POST /reboot
POST /stop
POST /refresh
POST /hardware
POST /software
POST /image/create
POST /image/restore
POST /setup
POST /image/create/basic
POST /image/create/incremental
POST /image/restore/basic
POST /image/restore/incremental
POST /run/schedule
This test covers requests that are missing one of the parameters in its
payload.
|
-
Property mode set to
100644
|
File size:
969 bytes
|
Line | |
---|
1 | import requests |
---|
2 | import unittest |
---|
3 | |
---|
4 | class TestPostStopMethods(unittest.TestCase): |
---|
5 | |
---|
6 | def setUp(self): |
---|
7 | self.url = 'http://localhost:8888/stop' |
---|
8 | self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'} |
---|
9 | self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] } |
---|
10 | |
---|
11 | def test_post(self): |
---|
12 | returned = requests.post(self.url, headers=self.headers, json=self.json) |
---|
13 | self.assertEqual(returned.status_code, 200) |
---|
14 | |
---|
15 | def test_no_payload(self): |
---|
16 | returned = requests.post(self.url, headers=self.headers, json=None) |
---|
17 | self.assertEqual(returned.status_code, 400) |
---|
18 | |
---|
19 | def test_malformed_payload(self): |
---|
20 | returned = requests.post(self.url, headers=self.headers, json={}) |
---|
21 | self.assertEqual(returned.status_code, 400) |
---|
22 | |
---|
23 | def test_get(self): |
---|
24 | returned = requests.get(self.url, headers=self.headers) |
---|
25 | self.assertEqual(returned.status_code, 405) |
---|
26 | |
---|
27 | if __name__ == '__main__': |
---|
28 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.
Download in other formats: