Respond with 503 when directory backend is locked
This commit is contained in:
parent
a4673e9661
commit
573dadf365
@ -28,6 +28,7 @@ module RemoteStorage
|
||||
|
||||
server.halt 401 unless permission
|
||||
if ["PUT", "DELETE"].include? request_method
|
||||
server.halt 503 if directory_backend(user).match /locked/
|
||||
server.halt 401 unless permission == "rw"
|
||||
end
|
||||
end
|
||||
|
@ -101,6 +101,38 @@ describe "App" do
|
||||
metadata.must_be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "directory backend configuration" do
|
||||
context "locked new backed" do
|
||||
before do
|
||||
redis.set "rs_config:dir_backend:phil", "new-locked"
|
||||
end
|
||||
|
||||
it "responds with 503" do
|
||||
put "/phil/food/aguacate", "si"
|
||||
|
||||
last_response.status.must_equal 503
|
||||
|
||||
metadata = redis.hgetall "rs_meta:phil:food/aguacate"
|
||||
metadata.must_be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "locked legacy backend" do
|
||||
before do
|
||||
redis.set "rs_config:dir_backend:phil", "legacy-locked"
|
||||
end
|
||||
|
||||
it "responds with 503" do
|
||||
put "/phil/food/aguacate", "si"
|
||||
|
||||
last_response.status.must_equal 503
|
||||
|
||||
metadata = redis.hgetall "rs_meta:phil:food/aguacate"
|
||||
metadata.must_be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user