mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 13:51:09 +08:00
DEV: New readonly mode. Only applies to non-staff (#16243)
This commit is contained in:

committed by
GitHub

parent
985afe1092
commit
6e53f4d913
@ -168,6 +168,33 @@ RSpec.describe Users::OmniauthCallbacksController do
|
||||
end
|
||||
end
|
||||
|
||||
context "in staff writes only mode" do
|
||||
use_redis_snapshotting
|
||||
|
||||
before do
|
||||
Discourse.enable_readonly_mode(Discourse::STAFF_WRITES_ONLY_MODE_KEY)
|
||||
end
|
||||
|
||||
it "returns a 503 for non-staff" do
|
||||
mock_auth(user.email, user.username, user.name)
|
||||
get "/auth/google_oauth2/callback.json"
|
||||
expect(response.status).to eq(503)
|
||||
logged_on_user = Discourse.current_user_provider.new(request.env).current_user
|
||||
|
||||
expect(logged_on_user).to eq(nil)
|
||||
end
|
||||
|
||||
it "completes for staff" do
|
||||
user.update!(admin: true)
|
||||
mock_auth(user.email, user.username, user.name)
|
||||
get "/auth/google_oauth2/callback.json"
|
||||
expect(response.status).to eq(302)
|
||||
logged_on_user = Discourse.current_user_provider.new(request.env).current_user
|
||||
|
||||
expect(logged_on_user).not_to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context "without an `omniauth.auth` env" do
|
||||
it "should return a 404" do
|
||||
get "/auth/eviltrout/callback"
|
||||
|
Reference in New Issue
Block a user