@@ -8,10 +8,9 @@ Resource variables.resource
88Resource ../variables.resource
99
1010Suite Setup Suite Setup
11- Suite Teardown Delete all plugins
1211
1312*** Variables ***
14- ${HELLO_WORLD_PLUGIN_VERSION } v0.0.8
13+ ${HELLO_WORLD_PLUGIN_VERSION } v0.0.11
1514
1615*** Test Cases ***
1716GET /plugin-manager with no plugins
@@ -23,12 +22,33 @@ GET /plugin-manager with no plugins
2322POST /plugin-manager?source={{pluginSource}}
2423 ${source } = Set Variable
2524 ... https://github.com/massalabs/station-massa-hello-world/releases/download/${HELLO_WORLD_PLUGIN_VERSION } /station-massa-hello-world_${OS } -${ARCH } .zip
25+ ${headers } = Create Dictionary Origin=http://localhost
2626 ${response } = POST
2727 ... ${API_URL } /plugin-manager
2828 ... params=source=${source }
29+ ... headers=${headers }
2930 ... expected_status=${STATUS_NO_CONTENT }
3031 Sleep 1 seconds # Wait for the plugin to be registered
3132
33+ POST /plugin-manager?source={{pluginSource}} should fail when Origin not provided
34+ ${source } = Set Variable
35+ ... https://github.com/massalabs/station-massa-hello-world/releases/download/${HELLO_WORLD_PLUGIN_VERSION } /station-massa-hello-world_${OS } -${ARCH } .zip
36+ ${response } = POST
37+ ... ${API_URL } /plugin-manager
38+ ... params=source=${source }
39+ ... expected_status=${STATUS_FORBIDDEN }
40+
41+ POST /plugin-manager?source={{pluginSource}} should fail when Origin not allowed
42+ ${source } = Set Variable
43+ ... https://github.com/massalabs/station-massa-hello-world/releases/download/${HELLO_WORLD_PLUGIN_VERSION } /station-massa-hello-world_${OS } -${ARCH } .zip
44+ ${headers } = Create Dictionary Origin=http://malicious.example.com
45+ ${response } = POST
46+ ... ${API_URL } /plugin-manager
47+ ... params=source=${source }
48+ ... headers=${headers }
49+ ... expected_status=${STATUS_FORBIDDEN }
50+
51+
3252GET /plugin-manager with one plugin
3353 ${response } = GET ${API_URL } /plugin-manager
3454 Status Should Be ${STATUS_OK }
@@ -45,25 +65,54 @@ GET /plugin-manager/{id}
4565POST /plugin-manager/{id}/execute with stop command
4666 ${id } = Get Plugin ID From Author and Name massa-labs hello-world
4767 ${data } = Create Dictionary command=stop
68+ ${headers } = Create Dictionary Origin=http://localhost
4869 ${response } = POST
4970 ... ${API_URL } /plugin-manager/${id } /execute
71+ ... headers=${headers }
5072 ... expected_status=${STATUS_NO_CONTENT }
5173 ... json=${data }
5274
75+ POST /plugin-manager/{id}/execute should fail when Origin not allowed
76+ ${id } = Get Plugin ID From Author and Name massa-labs hello-world
77+ ${data } = Create Dictionary command=stop
78+ ${headers } = Create Dictionary Origin=http://malicious.example.com
79+ ${response } = POST
80+ ... ${API_URL } /plugin-manager/${id } /execute
81+ ... headers=${headers }
82+ ... expected_status=${STATUS_FORBIDDEN }
83+ ... json=${data }
84+ ${data } = Create Dictionary command=start
85+ ${response } = POST
86+ ... ${API_URL } /plugin-manager/${id } /execute
87+ ... headers=${headers }
88+ ... expected_status=${STATUS_FORBIDDEN }
89+ ... json=${data }
90+ ${data } = Create Dictionary command=restart
91+ ${response } = POST
92+ ... ${API_URL } /plugin-manager/${id } /execute
93+ ... headers=${headers }
94+ ... expected_status=${STATUS_FORBIDDEN }
95+ ... json=${data }
96+
97+
5398POST /plugin-manager/{id}/execute with start command
5499 ${id } = Get Plugin ID From Author and Name massa-labs hello-world
55100 ${data } = Create Dictionary command=start
101+ ${headers } = Create Dictionary Origin=http://localhost
56102 ${response } = POST
57103 ... ${API_URL } /plugin-manager/${id } /execute
104+ ... headers=${headers }
58105 ... expected_status=${STATUS_NO_CONTENT }
59106 ... json=${data }
60107 Sleep 1 seconds # Wait for the plugin to be started
61108
62109POST /plugin-manager/{id}/execute with restart command
63110 ${id } = Get Plugin ID From Author and Name massa-labs hello-world
64111 ${data } = Create Dictionary command=restart
112+ ${headers } = Create Dictionary Origin=http://localhost
65113 ${response } = POST
66114 ... ${API_URL } /plugin-manager/${id } /execute
115+ ... headers=${headers }
67116 ... expected_status=${STATUS_NO_CONTENT }
68117 ... json=${data }
69118 Sleep 1 seconds # Wait for the plugin to be restarted
@@ -100,8 +149,10 @@ GET /plugin/{author}/{name}/
100149POST /plugins-manager/{id}/execute already started
101150 ${id } = Get Plugin ID From Author and Name massa-labs hello-world
102151 ${data } = Create Dictionary command=start
152+ ${headers } = Create Dictionary Origin=http://localhost
103153 ${response } = POST
104154 ... ${API_URL } /plugin-manager/${id } /execute
155+ ... headers=${headers }
105156 ... expected_status=${STATUS_BAD_REQUEST }
106157 ... json=${data }
107158
@@ -121,23 +172,21 @@ GET /plugin/${author}/${name} with invalid author and name
121172
122173POST /plugin-manager/{id}/execute with invalid id
123174 ${data } = Create Dictionary command=start
175+ ${headers } = Create Dictionary Origin=http://localhost
124176 ${response } = POST
125177 ... ${API_URL } /plugin-manager/invalid/execute
178+ ... headers=${headers }
126179 ... expected_status=${STATUS_NOT_FOUND }
127180 ... json=${data }
128181 Should Be Equal As Strings ${response.json()['code'] } Plugin-0001
129182 Should Be Equal As Strings ${response.json()['message'] } get plugin error: no plugin matching correlationID invalid
130183
131- DELETE /plugin-manager/{id} with invalid id
132- ${response } = DELETE ${API_URL } /plugin-manager/3829029 expected_status=${STATUS_INTERNAL_SERVER_ERROR }
133- Should Be Equal As Strings
134- ... ${response.json()['message'] }
135- ... getting plugin 3829029: no plugin matching correlationID 3829029
136-
137184POST /plugin-manager/{id}/execute with invalid body
138185 ${data } = Create Dictionary command=test
186+ ${headers } = Create Dictionary Origin=http://localhost
139187 ${response } = POST
140188 ... ${API_URL } /plugin-manager/invalid/execute
189+ ... headers=${headers }
141190 ... expected_status=${STATUS_UNPROCESSABLE_ENTITY }
142191 ... json=${data }
143192 Should Be Equal As Strings ${response.json()['code'] } 606
@@ -155,8 +204,10 @@ POST /plugin-manager/register with invalid id
155204 ... home=sunt
156205 ... api_spec=culpa enim sint aliqua
157206 ... url=oluptate
207+ ${headers } = Create Dictionary Origin=http://localhost
158208 ${response } = POST
159209 ... ${API_URL } /plugin-manager/register
210+ ... headers=${headers }
160211 ... expected_status=${STATUS_NOT_FOUND }
161212 ... json=${data }
162213
@@ -172,9 +223,47 @@ POST /plugin-manager/register with invalid body
172223 ... logo=id et sunt irure,
173224 ... home=sunt
174225 ... api_spec=culpa enim sint aliqua
226+ ${headers } = Create Dictionary Origin=http://localhost
175227 ${response } = POST
176228 ... ${API_URL } /plugin-manager/register
229+ ... headers=${headers }
177230 ... expected_status=${STATUS_UNPROCESSABLE_ENTITY }
178231 ... json=${data }
179232 Should Be Equal As Strings ${response.json()['code'] } 602
180233 Should Be Equal As Strings ${response.json()['message'] } body.url in body is required
234+
235+ POST /plugin-manager/register with not allowed origin header
236+ ${id } = Get Plugin ID From Author and Name massa-labs hello-world
237+ ${data } = Create Dictionary
238+ ... id=
239+ ... url=http://localhost:1234
240+ ${headers } = Create Dictionary Origin=http://malicious.example.com
241+ ${response } = POST
242+ ... ${API_URL } /plugin-manager/register
243+ ... headers=${headers }
244+ ... expected_status=${STATUS_FORBIDDEN }
245+ ... json=${data }
246+ ${response_str } = Convert To String ${response.content }
247+ Should Contain ${response_str } Forbidden: Operations restricted to authorized domains
248+
249+
250+ DELETE /plugin-manager/{id} with invalid id
251+ ${headers } = Create Dictionary Origin=http://localhost
252+ ${response } = DELETE ${API_URL } /plugin-manager/3829029 headers=${headers } expected_status=${STATUS_INTERNAL_SERVER_ERROR }
253+ Should Be Equal As Strings
254+ ... ${response.json()['message'] }
255+ ... getting plugin 3829029: no plugin matching correlationID 3829029
256+
257+ DELETE /plugin-manager/{id} with not allowed origin header
258+ ${id } = Get Plugin ID From Author and Name massa-labs hello-world
259+ ${headers } = Create Dictionary Origin=http://malicious.example.com
260+ ${response } = DELETE ${API_URL } /plugin-manager/${id } headers=${headers } expected_status=${STATUS_FORBIDDEN }
261+ ${response_str } = Convert To String ${response.content }
262+ Should Contain ${response_str } Forbidden: Operations restricted to authorized domains
263+
264+ DELETE /plugin-manager/{id} hello-world plugin
265+ ${id } = Get Plugin ID From Author and Name massa-labs hello-world
266+ ${headers } = Create Dictionary Origin=http://station.massa
267+ ${response } = DELETE ${API_URL } /plugin-manager/${id } headers=${headers } expected_status=${STATUS_NO_CONTENT }
268+ ${id } = Get Plugin ID From Author and Name massa-labs hello-world
269+ Should Be Equal As Strings ${id } ${EMPTY }
0 commit comments