mirror of
https://github.com/discourse/discourse.git
synced 2025-09-04 08:47:37 +08:00
FIX: Missing 2FA guards when sso is enabled or when local login is disabled.
This commit is contained in:
parent
e19ae6c55e
commit
939180efa8
4 changed files with 46 additions and 1 deletions
|
@ -89,5 +89,22 @@ RSpec.describe SecondFactorManager do
|
|||
expect(user.totp_enabled?).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when SSO is enabled' do
|
||||
it 'should return false' do
|
||||
SiteSetting.sso_url = 'http://someurl.com'
|
||||
SiteSetting.enable_sso = true
|
||||
|
||||
expect(user.totp_enabled?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when local login is disabled' do
|
||||
it 'should return false' do
|
||||
SiteSetting.enable_local_logins = false
|
||||
|
||||
expect(user.totp_enabled?).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -431,6 +431,31 @@ RSpec.describe UsersController do
|
|||
)
|
||||
end
|
||||
|
||||
describe 'when local logins are disabled' do
|
||||
it 'should return the right response' do
|
||||
SiteSetting.enable_local_logins = false
|
||||
|
||||
post "/users/second_factors.json", params: {
|
||||
password: 'somecomplicatedpassword'
|
||||
}
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when SSO is enabled' do
|
||||
it 'should return the right response' do
|
||||
SiteSetting.sso_url = 'http://someurl.com'
|
||||
SiteSetting.enable_sso = true
|
||||
|
||||
post "/users/second_factors.json", params: {
|
||||
password: 'somecomplicatedpassword'
|
||||
}
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
|
||||
it 'succeeds on correct password' do
|
||||
post "/users/second_factors.json", params: {
|
||||
password: 'somecomplicatedpassword'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue