2017-06-07 20:09:25 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Api::BaseController do
|
|
|
|
controller do
|
|
|
|
def success
|
|
|
|
head 200
|
|
|
|
end
|
|
|
|
|
2024-01-24 11:31:31 +01:00
|
|
|
def failure
|
2017-06-07 20:09:25 +02:00
|
|
|
FakeService.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-04-19 16:07:29 +02:00
|
|
|
it 'returns private cache control headers by default' do
|
|
|
|
routes.draw { get 'success' => 'api/base#success' }
|
|
|
|
get :success
|
|
|
|
expect(response.headers['Cache-Control']).to include('private, no-store')
|
|
|
|
end
|
|
|
|
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00
|
|
|
describe 'forgery protection' do
|
2017-06-07 20:09:25 +02:00
|
|
|
before do
|
|
|
|
routes.draw { post 'success' => 'api/base#success' }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not protect from forgery' do
|
|
|
|
ActionController::Base.allow_forgery_protection = true
|
2024-01-24 11:31:31 +01:00
|
|
|
post :success
|
2018-04-21 21:35:07 +02:00
|
|
|
expect(response).to have_http_status(200)
|
2017-06-07 20:09:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00
|
|
|
describe 'non-functional accounts handling' do
|
2022-01-28 00:46:42 +01:00
|
|
|
let(:user) { Fabricate(:user) }
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00
|
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
|
|
|
|
|
|
|
controller do
|
|
|
|
before_action :require_user!
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
routes.draw { post 'success' => 'api/base#success' }
|
|
|
|
allow(controller).to receive(:doorkeeper_token) { token }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http forbidden for unconfirmed accounts' do
|
|
|
|
user.update(confirmed_at: nil)
|
2024-01-24 11:31:31 +01:00
|
|
|
post :success
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http forbidden for pending accounts' do
|
|
|
|
user.update(approved: false)
|
2024-01-24 11:31:31 +01:00
|
|
|
post :success
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http forbidden for disabled accounts' do
|
|
|
|
user.update(disabled: true)
|
2024-01-24 11:31:31 +01:00
|
|
|
post :success
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http forbidden for suspended accounts' do
|
|
|
|
user.account.suspend!
|
2024-01-24 11:31:31 +01:00
|
|
|
post :success
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 10:48:50 +02:00
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2017-06-07 20:09:25 +02:00
|
|
|
end
|