@@ -74,12 +74,12 @@ describe("Admin API #" .. strategy, function()
74
74
end )
75
75
76
76
describe (" /upstreams/{upstream}/targets/" , function ()
77
- describe (" POST " , function ()
77
+ describe (" PUT " , function ()
78
78
it_content_types (" creates a target with defaults" , function (content_type )
79
79
return function ()
80
80
local upstream = bp .upstreams :insert { slots = 10 }
81
81
local res = assert (client :send {
82
- method = " POST " ,
82
+ method = " PUT " ,
83
83
path = " /upstreams/" .. upstream .name .. " /targets/" ,
84
84
body = {
85
85
target = " mashape.com" ,
@@ -98,7 +98,7 @@ describe("Admin API #" .. strategy, function()
98
98
return function ()
99
99
local upstream = bp .upstreams :insert { slots = 10 }
100
100
local res = assert (client :send {
101
- method = " POST " ,
101
+ method = " PUT " ,
102
102
path = " /upstreams/" .. upstream .name .. " /targets/" ,
103
103
body = {
104
104
target = " mashape.com:123" ,
@@ -119,7 +119,7 @@ describe("Admin API #" .. strategy, function()
119
119
return function ()
120
120
local upstream = bp .upstreams :insert { slots = 10 }
121
121
local res = assert (client :send {
122
- method = " POST " ,
122
+ method = " PUT " ,
123
123
path = " /upstreams/" .. upstream .name .. " /targets/" ,
124
124
body = {
125
125
target = " zero.weight.test:8080" ,
@@ -146,7 +146,7 @@ describe("Admin API #" .. strategy, function()
146
146
return function ()
147
147
local upstream = bp .upstreams :insert { slots = 10 }
148
148
local res = assert (client :send {
149
- method = " POST " ,
149
+ method = " PUT " ,
150
150
path = " /upstreams/" .. upstream .name .. " /targets/" ,
151
151
body = {
152
152
target = " single-target.test:8080" ,
@@ -163,7 +163,7 @@ describe("Admin API #" .. strategy, function()
163
163
assert .are .equal (1 , json .weight )
164
164
165
165
local res = assert (client :send {
166
- method = " POST " ,
166
+ method = " PUT " ,
167
167
path = " /upstreams/" .. upstream .name .. " /targets/" ,
168
168
body = {
169
169
target = " single-target.test:8080" ,
@@ -183,7 +183,7 @@ describe("Admin API #" .. strategy, function()
183
183
it (" handles malformed JSON body" , function ()
184
184
local upstream = bp .upstreams :insert { slots = 10 }
185
185
local res = assert (client :request {
186
- method = " POST " ,
186
+ method = " PUT " ,
187
187
path = " /upstreams/" .. upstream .name .. " /targets/" ,
188
188
body = ' {"hello": "world"' ,
189
189
headers = {[" Content-Type" ] = " application/json" }
@@ -197,7 +197,7 @@ describe("Admin API #" .. strategy, function()
197
197
local upstream = bp .upstreams :insert { slots = 10 }
198
198
-- Missing parameter
199
199
local res = assert (client :send {
200
- method = " POST " ,
200
+ method = " PUT " ,
201
201
path = " /upstreams/" .. upstream .name .. " /targets/" ,
202
202
body = {
203
203
weight = weight_min ,
@@ -211,7 +211,7 @@ describe("Admin API #" .. strategy, function()
211
211
212
212
-- Invalid target parameter
213
213
res = assert (client :send {
214
- method = " POST " ,
214
+ method = " PUT " ,
215
215
path = " /upstreams/" .. upstream .name .. " /targets/" ,
216
216
body = {
217
217
target = " some invalid host name" ,
@@ -225,7 +225,7 @@ describe("Admin API #" .. strategy, function()
225
225
226
226
-- Invalid weight parameter
227
227
res = assert (client :send {
228
- method = " POST " ,
228
+ method = " PUT " ,
229
229
path = " /upstreams/" .. upstream .name .. " /targets/" ,
230
230
body = {
231
231
target = " mashape.com" ,
@@ -240,7 +240,7 @@ describe("Admin API #" .. strategy, function()
240
240
end
241
241
end )
242
242
243
- for _ , method in ipairs ({" PUT " , " PATCH" , " DELETE" }) do
243
+ for _ , method in ipairs ({" POST " , " PATCH" , " DELETE" }) do
244
244
it_content_types (" returns 405 on " .. method , function (content_type )
245
245
return function ()
246
246
local upstream = bp .upstreams :insert { slots = 10 }
@@ -337,7 +337,7 @@ describe("Admin API #" .. strategy, function()
337
337
338
338
for i = 1 , # weights do
339
339
local status , body = client_send ({
340
- method = " POST " ,
340
+ method = " PUT " ,
341
341
path = " /upstreams/" .. upstream .name .. " /targets" ,
342
342
headers = {
343
343
[" Content-Type" ] = " application/json" ,
@@ -668,7 +668,7 @@ describe("Admin API #" .. strategy, function()
668
668
local json = assert (cjson .decode (body ))
669
669
670
670
status , body = assert (client_send ({
671
- method = " POST " ,
671
+ method = " PUT " ,
672
672
path = " /upstreams/" .. upstream .id .. " /targets" ,
673
673
headers = {[" Content-Type" ] = " application/json" },
674
674
body = {
@@ -691,7 +691,7 @@ describe("Admin API #" .. strategy, function()
691
691
local expected = (i >= 3 and j >= 4 ) and 204 or 404
692
692
local path = " /upstreams/" .. u .. " /targets/" .. t .. " /" .. e
693
693
local status = assert (client_send {
694
- method = " POST " ,
694
+ method = " PUT " ,
695
695
path = " /upstreams/" .. u .. " /targets/" .. t .. " /" .. e
696
696
})
697
697
assert .same (expected , status , " bad status for path " .. path )
@@ -703,7 +703,7 @@ describe("Admin API #" .. strategy, function()
703
703
it (" flips the target status from UNHEALTHY to HEALTHY" , function ()
704
704
local status , body , json
705
705
status , body = assert (client_send {
706
- method = " POST " ,
706
+ method = " PUT " ,
707
707
path = target_path .. " /unhealthy"
708
708
})
709
709
assert .same (204 , status , body )
@@ -716,7 +716,7 @@ describe("Admin API #" .. strategy, function()
716
716
assert .same (target .target , json .data [1 ].target )
717
717
assert .same (" UNHEALTHY" , json .data [1 ].health )
718
718
status = assert (client_send {
719
- method = " POST " ,
719
+ method = " PUT " ,
720
720
path = target_path .. " /healthy"
721
721
})
722
722
assert .same (204 , status )
@@ -733,7 +733,7 @@ describe("Admin API #" .. strategy, function()
733
733
it (" flips the target status from HEALTHY to UNHEALTHY" , function ()
734
734
local status , body , json
735
735
status = assert (client_send {
736
- method = " POST " ,
736
+ method = " PUT " ,
737
737
path = target_path .. " /healthy"
738
738
})
739
739
assert .same (204 , status )
@@ -746,7 +746,7 @@ describe("Admin API #" .. strategy, function()
746
746
assert .same (target .target , json .data [1 ].target )
747
747
assert .same (" HEALTHY" , json .data [1 ].health )
748
748
status = assert (client_send {
749
- method = " POST " ,
749
+ method = " PUT " ,
750
750
path = target_path .. " /unhealthy"
751
751
})
752
752
assert .same (204 , status )
0 commit comments