source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/account_page_policy_test.rb | Ruby | mit | 97 | main | 363 | require "test_helper"
require "support/policy_helpers"
class AccountPagePolicyTest < ActiveSupport::TestCase
include PolicyHelpers
should "allow logged in users to see show irrespective of their role" do
assert permit?(build(:user), nil, :show)
end
should "not allow anonymous visitors to see show" do
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/account/emails_policy_test.rb | Ruby | mit | 97 | main | 367 | require "test_helper"
require "support/policy_helpers"
class Account::EmailsPolicyTest < ActiveSupport::TestCase
include PolicyHelpers
should "allow logged in users to see show irrespective of their role" do
assert permit?(build(:user), nil, :edit)
end
should "not allow anonymous visitors to see edit" do... |
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/account/roles_policy_test.rb | Ruby | mit | 97 | main | 900 | require "test_helper"
require "support/policy_helpers"
class Account::RolesPolicyTest < ActiveSupport::TestCase
include PolicyHelpers
context "edit?" do
should "allow logged in users to see edit irrespective of their role" do
assert permit?(build(:user), nil, :edit)
end
should "not allow anonym... |
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/account/activities_policy_test.rb | Ruby | mit | 97 | main | 371 | require "test_helper"
require "support/policy_helpers"
class Account::ActivitiesPolicyTest < ActiveSupport::TestCase
include PolicyHelpers
should "allow logged in users to see show irrespective of their role" do
assert permit?(build(:user), nil, :show)
end
should "not allow anonymous visitors to see show... |
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/account/organisations_policy_test.rb | Ruby | mit | 97 | main | 908 | require "test_helper"
require "support/policy_helpers"
class Account::OrganisationsPolicyTest < ActiveSupport::TestCase
include PolicyHelpers
context "edit?" do
should "allow logged in users to see edit irrespective of their role" do
assert permit?(build(:user), nil, :edit)
end
should "not allo... |
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/account/application_policy_test.rb | Ruby | mit | 97 | main | 4,788 | require "test_helper"
require "support/policy_helpers"
class Account::ApplicationPolicyTest < ActiveSupport::TestCase
include PolicyHelpers
setup do
@current_user = create(:user)
@application = create(:application)
end
%i[show index view_permissions].each do |aliased_method|
context "##{aliased_m... |
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/account/passwords_policy_test.rb | Ruby | mit | 97 | main | 370 | require "test_helper"
require "support/policy_helpers"
class Account::PasswordsPolicyTest < ActiveSupport::TestCase
include PolicyHelpers
should "allow logged in users to see edit irrespective of their role" do
assert permit?(build(:user), nil, :edit)
end
should "not allow anonymous visitors to see edit"... |
github | alphagov/signon | https://github.com/alphagov/signon | test/policies/users/application_policy_test.rb | Ruby | mit | 97 | main | 5,246 | require "test_helper"
require "support/policy_helpers"
class Users::ApplicationPolicyTest < ActiveSupport::TestCase
include PolicyHelpers
include PunditHelpers
setup do
@current_user = create(:user)
@user = create(:user)
@application = create(:application)
end
%i[show index view_permissions].ea... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/user_account_helpers.rb | Ruby | mit | 97 | main | 1,065 | module UserAccountHelpers
# usage: accept_invitation(password: "<new password>", invitation_token: "<token>")
def accept_invitation(options)
raise "Please provide password" unless options[:password]
raise "Please provide invitation token" unless options[:invitation_token]
signout
visit accept_user_... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/token_auth_helpers.rb | Ruby | mit | 97 | main | 315 | module TokenAuthHelpers
def get_valid_token
User.last.authorisations.first
end
def get_expired_token
token = get_valid_token
token.update_column(:created_at, 3.days.ago)
token.update_column(:expires_in, 30)
token
end
def get_revoked_token
get_valid_token.tap(&:revoke)
end
end |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/user_helpers.rb | Ruby | mit | 97 | main | 1,100 | module UserHelpers
def signin_with(user = nil, email: nil, password: nil, second_step: true, set_up_2sv: true)
user ||= User.find_by(email:)
email ||= user.email
password ||= user.password
if user && user.require_2sv? && user.otp_secret_key.blank? && set_up_2sv
user.update!(otp_secret_key: ROTP... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/removing_access_helpers.rb | Ruby | mit | 97 | main | 1,530 | module RemovingAccessHelpers
def assert_remove_access_from_self(application, current_user)
assert_edit_self
assert_remove_access(application, current_user, grantee_is_self: true)
end
def assert_remove_access_from_other_user(application, other_user)
assert_edit_other_user(other_user)
assert_remove... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/pundit_helpers.rb | Ruby | mit | 97 | main | 672 | module PunditHelpers
def stub_policy(current_user, record, **options)
policy_class = options.delete(:policy_class) || Pundit::PolicyFinder.new(record).policy
record = record.last if record.is_a?(Array)
policy = stub_everything("policy", options).responds_like_instance_of(policy_class)
policy_class.stu... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/flash_helpers.rb | Ruby | mit | 97 | main | 552 | module FlashHelpers
def assert_flash_content(content)
flash = find_flash
case content
when String
assert flash.has_content?(content)
when Array
content.each { |item| assert flash.has_content?(item) }
end
end
def refute_flash_content(content)
flash = find_flash
case conte... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/managing_two_sv_helpers.rb | Ruby | mit | 97 | main | 3,225 | module ManagingTwoSvHelpers
include ActiveJob::TestHelper
def sign_in_as_and_edit_user(sign_in_as, user_to_edit)
visit root_path
signin_with(sign_in_as)
visit edit_user_path(user_to_edit)
end
def exemption_message(initiator, reason, expiry_date)
"Exempted from 2-step verification by #{initiato... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/editing_users_helpers.rb | Ruby | mit | 97 | main | 474 | module EditingUsersHelpers
def assert_edit_self
visit account_applications_path
assert page.has_content?("GOV.UK apps")
end
def assert_edit_other_user(other_user)
visit user_applications_path(other_user)
assert page.has_content?("#{other_user.name}'s applications")
end
def refute_edit_othe... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/policy_helpers.rb | Ruby | mit | 97 | main | 208 | module PolicyHelpers
def permit?(user, record, action)
self.class.to_s.gsub(/Test/, "").constantize.new(user, record).public_send("#{action}?")
end
def forbid?(*args)
!permit?(*args)
end
end |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/updating_permissions_helpers.rb | Ruby | mit | 97 | main | 1,904 | module UpdatingPermissionsHelpers
def assert_update_permissions_for_self(application, current_user, grant: [], revoke: [])
assert_edit_self
assert_update_permissions(application, current_user, grant:, revoke:)
end
def assert_update_permissions_for_other_user(application, other_user, grant: [], revoke: []... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/granting_access_helpers.rb | Ruby | mit | 97 | main | 1,453 | module GrantingAccessHelpers
def assert_grant_access_to_self(application, current_user)
assert_edit_self
assert_grant_access(application, current_user, grantee_is_self: true)
end
def assert_grant_access_to_other_user(application, other_user)
assert_edit_other_user(other_user)
assert_grant_access(... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/email_helpers.rb | Ruby | mit | 97 | main | 240 | require "capybara/email"
module EmailHelpers
include Capybara::Email::DSL
def last_email
all_emails.last
end
def last_email_for(email_address)
all_emails.reverse.find { |email| email.to.include? email_address }
end
end |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/password_helpers.rb | Ruby | mit | 97 | main | 976 | module PasswordHelpers
def change_password(options)
# this method assumes that the user is logged in
visit root_path
click_link "Change your password"
fill_in "Current password", with: options[:old]
fill_in "New password", with: options[:new]
fill_in "Confirm new password", with: options[:new_... |
github | alphagov/signon | https://github.com/alphagov/signon | test/support/autocomplete_helper.rb | Ruby | mit | 97 | main | 405 | require "capybara/rails"
class AutocompleteHelper
include Capybara::DSL
def clear_selection
click_button "Clear selection"
end
def select_autocomplete_option(option_string)
autocomplete_input_element = find(".autocomplete__input")
autocomplete_input_element.fill_in with: option_string
autocom... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/two_step_verification_helper_test.rb | Ruby | mit | 97 | main | 2,263 | require "test_helper"
class TwoStepVerificationHelperTest < ActionView::TestCase
setup do
@user = build(:user)
@secret = ROTP::Base32.random_base32
ROTP::Base32.stubs(random_base32: @secret)
end
context "otp_secret_key_uri(user: @user, otp_secret_key: @secret)" do
should "include the secret key ... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/users_with_access_helper_test.rb | Ruby | mit | 97 | main | 2,036 | require "test_helper"
class UsersWithAccessHelperTest < ActionView::TestCase
test "formatted_user_name links to users with name" do
user = build(:user, id: 1, name: "User Name")
user.stubs(:unusable_account?).returns(false)
assert_equal '<a class="govuk-link" href="/users/1/edit">User Name</a>', formatt... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/users_helper_test.rb | Ruby | mit | 97 | main | 16,496 | require "test_helper"
class UsersHelperTest < ActionView::TestCase
include ApplicationHelper
test "sync_needed? should work with user permissions not synced yet" do
application = create(:application)
user = create(:user)
user.grant_application_signin_permission(application)
assert_nothing_raised ... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/application_table_helper_test.rb | Ruby | mit | 97 | main | 11,416 | require "test_helper"
class ApplicationTableHelperTest < ActionView::TestCase
include PunditHelpers
context "#account_applications_grant_access_link" do
setup do
@user = build(:user)
stubs(:current_user).returns(@user)
@application = create(:application)
end
should "generate a grant... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/application_helper_test.rb | Ruby | mit | 97 | main | 2,434 | require "test_helper"
class ApplicationHelperTest < ActionView::TestCase
test "#sensitive_query_parameters? returns false when no parameters in the URL" do
self.request = ActionDispatch::Request.new(Rack::MockRequest.env_for("/nothing-to-hide"))
assert_not sensitive_query_parameters?
end
test "#sensitiv... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/organisation_helper_test.rb | Ruby | mit | 97 | main | 1,903 | require "test_helper"
class OrganisationHelperTest < ActionView::TestCase
setup do
@gds = create(:organisation, name: "Government Digital Service", abbreviation: "GDS")
@gas = create(:organisation, name: "Government Analogue Service", abbreviation: "GAS")
@unabbreviated = create(:organisation, name: "unA... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/batch_invitations_helper_test.rb | Ruby | mit | 97 | main | 3,905 | require "test_helper"
class BatchInvitationsHelperTest < ActionView::TestCase
context "#batch_invite_status_message" do
should "state number of users processed so far when still in progress" do
batch_invitation = create(:batch_invitation, :in_progress)
create(:batch_invitation_user, outcome: "failed"... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/root_helper_test.rb | Ruby | mit | 97 | main | 1,473 | require "test_helper"
class RootHelperTest < ActionView::TestCase
attr_reader :application, :current_user
setup do
@application = build(:application)
@current_user = build(:user)
end
context "#gds_only_application_and_non_gds_user?" do
should "returns false if application is nil" do
assert_... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/application_permissions_helper_test.rb | Ruby | mit | 97 | main | 5,090 | require "test_helper"
class ApplicationPermissionsHelperTest < ActionView::TestCase
context "#permissions_updated_description" do
setup do
@application = create(:application, name: "Whitehall", with_non_delegated_supported_permissions: ["Permission 1"])
user = create(:user, with_permissions: { @appli... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/application_access_helper_test.rb | Ruby | mit | 97 | main | 1,879 | require "test_helper"
class ApplicationAccessHelperTest < ActionView::TestCase
setup do
@application = create(:application, name: "Whitehall")
stubs(:current_user).returns(create(:user))
end
context "#access_granted_description" do
context "when the user is granting themself access" do
should ... |
github | alphagov/signon | https://github.com/alphagov/signon | test/helpers/account_helper_test.rb | Ruby | mit | 97 | main | 1,247 | require "test_helper"
class AccountHelperTest < ActionView::TestCase
context "#two_step_verification_page_title" do
should "say 'change' if current_user already has 2SV setup" do
user = build(:two_step_enabled_user)
stubs(:current_user).returns(user)
assert_equal "Change your 2-step verificati... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/mandate_2sv_for_organisation_test.rb | Ruby | mit | 97 | main | 3,416 | require "test_helper"
class Mandate2svForOrganisationTest < ActionDispatch::IntegrationTest
context "Changing 2sv status of an Organisation" do
context "when logged in as a super admin" do
setup do
@super_admin = create(:superadmin_user)
visit root_path
signin_with(@super_admin)
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/api_users_test.rb | Ruby | mit | 97 | main | 5,367 | require_relative "../test_helper"
class ManageApiUsersTest < ActionDispatch::IntegrationTest
context "as Superadmin" do
setup do
@application = create(:application, with_non_delegated_supported_permissions: %w[write])
@superadmin = create(:superadmin_user)
visit new_user_session_path
sig... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/volatile_lock_test.rb | Ruby | mit | 97 | main | 1,775 | require "test_helper"
class VolatileLockTest < ActiveSupport::TestCase
def teardown
redis.del("foo", "bar")
end
def redis
Redis.new
end
def volatile_lock(key, expiration_time = 1.second)
VolatileLock.new(key, expiration_time)
end
test "starts by deleting possibly stale locks created by the... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/dashboard_test.rb | Ruby | mit | 97 | main | 2,038 | require "test_helper"
class DashboardTest < ActionDispatch::IntegrationTest
should "notify the user if they've not been assigned any applications" do
app = create(:application, name: "MyApp", api_only: true)
user = create(:user, with_signin_permissions_for: [app])
visit root_path
signin_with(user)
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/password_reset_test.rb | Ruby | mit | 97 | main | 4,421 | require "test_helper"
require "support/password_helpers"
class PasswordResetTest < ActionDispatch::IntegrationTest
include PasswordHelpers
include ActiveJob::TestHelper
BLANKET_RESET_MESSAGE = "If your email address is recognised, you’ll receive an email with instructions about how to reset your password.".free... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/user_suspension_test.rb | Ruby | mit | 97 | main | 562 | require "test_helper"
class UserSuspensionTest < ActionDispatch::IntegrationTest
setup do
@user = create(:user)
@user.suspend("gross misconduct")
end
should "prevent users from signing in" do
visit new_user_session_path
signin_with(@user)
assert_response_contains("account has been suspended... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/user_locking_test.rb | Ruby | mit | 97 | main | 1,328 | require "test_helper"
class UserLockingTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
should "trigger if the user typed a wrong password too many times" do
perform_enqueued_jobs do
user = create(:user)
visit root_path
8.times { signin_with(email: user.email, password: "... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/session_timeout_test.rb | Ruby | mit | 97 | main | 567 | require "test_helper"
class SessionTimeoutTest < ActionDispatch::IntegrationTest
setup do
@user_email = "email@example.com"
@user_password = "some password with various $ymb0l$"
@user = create(:user, email: @user_email, password: @user_password)
end
should "not extend an expired session by viewing t... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/user_research_recruitment_banner_test.rb | Ruby | mit | 97 | main | 2,693 | require "test_helper"
class UserResearchRecruitmentBannerTest < ActionDispatch::IntegrationTest
should "not display the banner on the login page" do
visit new_user_session_path
assert_not has_content?(user_research_recruitment_banner_title)
end
should "display the banner on the dashboard" do
user =... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/doorkeeper_integration_test.rb | Ruby | mit | 97 | main | 4,265 | require "test_helper"
class DoorkeeperIntegrationTest < ActionDispatch::IntegrationTest
test "prevents access to Doorkeeper's /oauth/applications page" do
visit "/oauth/applications"
rescue ActionController::RoutingError => e
assert_equal 'No route matches [GET] "/oauth/applications"', e.message
end
t... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/batch_inviting_users_test.rb | Ruby | mit | 97 | main | 6,470 | require "test_helper"
class BatchInvitingUsersTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
setup do
@cabinet_office = create(:organisation, slug: "cabinet-office", name: "Cabinet Office")
@department_of_hats = create(:organisation, slug: "department-of-hats", name: "Department of H... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/two_step_verification_test.rb | Ruby | mit | 97 | main | 5,943 | require "test_helper"
class TwoStepVerificationTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
context "setting a 2SV code" do
setup do
@new_secret = ROTP::Base32.random_base32
@original_secret = ROTP::Base32.random_base32
ROTP::Base32.stubs(random_base32: @new_secret)
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/cookies_security_test.rb | Ruby | mit | 97 | main | 629 | require "test_helper"
class CookiesSecurityTest < ActionDispatch::IntegrationTest
should "set the right cookies when signing in" do
user = FactoryBot.create(:two_step_enabled_user)
sign_up_with user.email, user.password
visit new_user_session_path
response_cookies = Capybara.current_session.driver.re... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/api_authentication_test.rb | Ruby | mit | 97 | main | 2,565 | require "test_helper"
require "support/token_auth_helpers"
class ApiAuthenticationTest < ActionDispatch::IntegrationTest
include TokenAuthHelpers
def access_user_endpoint(token = nil, params = {})
headers = token.nil? ? {} : { "HTTP_AUTHORIZATION" => "Bearer #{token}" }
get "/user.json", params:, headers:... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/user_agent_test.rb | Ruby | mit | 97 | main | 695 | require "test_helper"
require "support/password_helpers"
class UserAgentIntegrationTest < ActionDispatch::IntegrationTest
include PasswordHelpers
setup do
@user = create(:user, name: "Normal User")
end
test "record user's user-agent string on login" do
user_agent_test = "Mozilla/5.0 (Macintosh; Intel... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/two_step_verification_prompt_test.rb | Ruby | mit | 97 | main | 1,048 | require "test_helper"
class TwoStepVerificationPromptTest < ActionDispatch::IntegrationTest
context "when the user has had 2-step verification mandated" do
setup do
@user = create(:two_step_mandated_superadmin_user)
visit users_path
signin_with(@user, set_up_2sv: false)
end
should "pro... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/sign_in_test.rb | Ruby | mit | 97 | main | 11,995 | require "test_helper"
class SignInTest < ActionDispatch::IntegrationTest
setup do
@organisation = create(:organisation, name: "Ministry of Lindy-hop", slug: "ministry-of-lindy-hop")
@email = "email@example.com"
@password = "some password with various $ymb0l$"
@user = create(:user_in_organisation, ema... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/updating_permissions_for_apps_with_many_permissions_test.rb | Ruby | mit | 97 | main | 6,104 | require "test_helper"
class UpdatingPermissionsForAppsWithManyPermissionsTest < ActionDispatch::IntegrationTest
# Also see: Account::UpdatingPermissionsTest, Users::UpdatingPermissionsTest
autocomplete_helper = AutocompleteHelper.new
def navigate_to_update_my_own_permissions_page
visit new_user_session_pat... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/event_log_creation_test.rb | Ruby | mit | 97 | main | 7,298 | require "test_helper"
require "support/password_helpers"
class EventLogCreationIntegrationTest < ActionDispatch::IntegrationTest
include PasswordHelpers
setup do
@admin = create(:admin_user, name: "Admin User")
@user = create(:user, name: "Normal User")
end
test "record successful login" do
visit... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/inviting_users_test.rb | Ruby | mit | 97 | main | 15,645 | require "test_helper"
class InvitingUsersTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
should "ask the invited user to set a password" do
user = User.invite!(name: "Jim", email: "jim@web.com")
visit accept_user_invitation_path(invitation_token: user.raw_invitation_token)
fill_i... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/sign_out_test.rb | Ruby | mit | 97 | main | 552 | require "test_helper"
class SignOutTest < ActionDispatch::IntegrationTest
setup do
@user = create(:user_in_organisation, email: "email@example.com", password: "some password with various $ymb0l$")
visit root_path
end
should "perform reauth on downstream apps" do
signin_with(@user)
ReauthEnforcer... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/email_change_test.rb | Ruby | mit | 97 | main | 7,133 | require "test_helper"
class EmailChangeTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
context "by an admin" do
setup do
@admin = create(:admin_user)
end
context "for an active user" do
should "send a notification email and not confirmation email" do
perform_e... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/authorise_application_test.rb | Ruby | mit | 97 | main | 4,010 | require "test_helper"
class AuthoriseApplicationTest < ActionDispatch::IntegrationTest
setup do
@app = create(:application, name: "MyApp")
@user = create(:user, with_signin_permissions_for: [@app])
end
context "when the user has had 2SV mandated" do
setup do
@user.update!(require_2sv: true)
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/granting_access_test.rb | Ruby | mit | 97 | main | 850 | require "test_helper"
class Account::GrantingAccessTest < ActionDispatch::IntegrationTest
setup { @application = create(:application) }
%w[superadmin admin].each do |admin_role|
context "as a #{admin_role}" do
setup do
@user = create(:"#{admin_role}_user")
visit new_user_session_path
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/updating_organisation_test.rb | Ruby | mit | 97 | main | 1,985 | require "test_helper"
class Account::UpdatingOrganisationTest < ActionDispatch::IntegrationTest
should "display read-only values for users who aren't GOVUK Admins" do
organisation = create(:organisation, name: "Department for Viability")
non_govuk_admin_user = create(:super_organisation_admin_user, organisat... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/updating_permissions_test.rb | Ruby | mit | 97 | main | 3,135 | require "test_helper"
class Account::UpdatingPermissionsTest < ActionDispatch::IntegrationTest
# See also: UpdatingPermissionsForAppsWithManyPermissionsTest
context "for all apps" do
setup do
@application = create(:application)
@old_delegated_grantable_permission,
@new_delegated_grantable_p... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/password_change_test.rb | Ruby | mit | 97 | main | 5,015 | require "test_helper"
require "support/password_helpers"
class Account::PasswordChangeTest < ActionDispatch::IntegrationTest
include PasswordHelpers
context "normal user" do
setup do
@original_password = "some v3ry s3cure password"
@user = create(:user, email: "jane.user@example.com", password: @o... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/roles_test.rb | Ruby | mit | 97 | main | 925 | require "test_helper"
class Account::RolesTest < ActionDispatch::IntegrationTest
context "#show" do
should "display read-only values for users who aren't GOVUK Admins" do
non_govuk_admin_user = create(:super_organisation_admin_user)
visit new_user_session_path
signin_with non_govuk_admin_user
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/removing_access_test.rb | Ruby | mit | 97 | main | 1,612 | require "test_helper"
class Account::RemovingAccessTest < ActionDispatch::IntegrationTest
setup do
@application = create(:application)
@user = create(:user_in_organisation, with_signin_permissions_for: [@application])
end
context "when the signin permission is delegated" do
setup { @application.sign... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/activities_test.rb | Ruby | mit | 97 | main | 1,117 | require "test_helper"
class Account::ActivitiesTest < ActionDispatch::IntegrationTest
context "#show" do
should "list user's EventLogs in table" do
user = create(:user)
visit new_user_session_path
signin_with user
visit account_activity_path
assert page.has_selector? "td", text: ... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/account/account_test.rb | Ruby | mit | 97 | main | 2,467 | require "test_helper"
class AccountTest < ActionDispatch::IntegrationTest
context "#show" do
should "not be accessible to signed out users" do
visit account_path
assert_current_url new_user_session_path
end
should "link to Change email/password, Manage permissions, Change 2SV, role & org fo... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/applications/edit_test.rb | Ruby | mit | 97 | main | 2,445 | require "test_helper"
class ApplicationsEditTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
context "logged in as an superadmin" do
setup do
@application = create(:application)
@superadmin = create(:superadmin_user)
visit new_user_session_path
signin_with(@superad... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/applications/users_with_access_test.rb | Ruby | mit | 97 | main | 684 | require "test_helper"
class ApplicationsUsersWithAccessTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
context "logged in as an superadmin" do
setup do
@application = create(:application)
visit new_user_session_path
signin_with(create(:superadmin_user))
end
sho... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/applications/access_logs_test.rb | Ruby | mit | 97 | main | 1,928 | require "test_helper"
class ApplicationsAccessLogsIntegrationTest < ActionDispatch::IntegrationTest
setup do
@application = create(:application, name: "app-name", description: "app-description")
@user = create(:user, name: "Normal User")
end
test "users don't have permission to view account access log" ... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/applications/monthly_access_stats_test.rb | Ruby | mit | 97 | main | 2,744 | require "test_helper"
class ApplicationsMonthlyAccessStatsIntegrationTest < ActionDispatch::IntegrationTest
setup do
@application = create(:application, name: "app-name", description: "app-description")
@user = create(:user, name: "Normal User")
end
test "users don't have permission to view account acce... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/roles_test.rb | Ruby | mit | 97 | main | 1,848 | require "test_helper"
class Users::RolesTest < ActionDispatch::IntegrationTest
setup do
@super_admin = create(:superadmin_user)
end
# TODO: there's some stuff that can be refactored here - common stuff into helpers
def sign_in_as_and_edit_user(sign_in_as, user_to_edit)
visit root_path
signin_with(... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/account_access_logs_test.rb | Ruby | mit | 97 | main | 3,907 | require "test_helper"
require "support/password_helpers"
class Users::AccountAccessLogsIntegrationTest < ActionDispatch::IntegrationTest
include PasswordHelpers
setup do
@admin = create(:admin_user, name: "Admin User")
@user = create(:user, name: "Normal User")
end
test "users don't have permission t... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/two_step_verification_test.rb | Ruby | mit | 97 | main | 11,661 | require "test_helper"
class Users::TwoStepVerificationTest < ActionDispatch::IntegrationTest
include EmailHelpers
include ManagingTwoSvHelpers
setup do
@organisation = create(:organisation)
@child_organisation = create(:organisation, parent: @organisation)
end
context "Mandating and resetting 2-ste... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/status_test.rb | Ruby | mit | 97 | main | 460 | require "test_helper"
require "support/password_helpers"
class Users::StatusTest < ActionDispatch::IntegrationTest
include PasswordHelpers
setup do
@admin = create(:admin_user)
@user = create(:user, suspended_at: 1.day.ago, reason_for_suspension: "Inactivity")
end
test "User status appears on the edi... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/users_test.rb | Ruby | mit | 97 | main | 3,453 | require "test_helper"
class UsersTest < ActionDispatch::IntegrationTest
context "logged in as an admin" do
setup do
use_javascript_driver
current_time = Time.current
Timecop.freeze(current_time)
@admin = create(:admin_user, name: "Admin User", email: "admin@example.com")
visit new... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/granting_access_test.rb | Ruby | mit | 97 | main | 4,377 | require "test_helper"
class Users::GrantingAccessTest < ActionDispatch::IntegrationTest
setup do
@application = create(:application, with_delegated_supported_permissions: [SupportedPermission::SIGNIN_NAME])
@granter = create(:user_in_organisation, with_signin_permissions_for: [@application])
@grantee = c... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/updating_organisation_test.rb | Ruby | mit | 97 | main | 2,110 | require "test_helper"
class Users::UpdatingOrganisationTest < ActionDispatch::IntegrationTest
should "display read-only values for users who aren't GOVUK Admins" do
organisation = create(:organisation, name: "Department for Viability")
user = create(:user, organisation:)
non_govuk_admin_user = create(:su... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/updating_permissions_test.rb | Ruby | mit | 97 | main | 6,878 | require "test_helper"
class Users::UpdatingPermissionsTest < ActionDispatch::IntegrationTest
# See also: UpdatingPermissionsForAppsWithManyPermissionsTest
context "for all apps" do
setup do
@application = create(:application)
@old_delegated_grantable_permission,
@new_delegated_grantable_per... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/removing_access_test.rb | Ruby | mit | 97 | main | 4,450 | require "test_helper"
class Users::RemovingAccessTest < ActionDispatch::IntegrationTest
setup do
@application = create(:application, with_delegated_supported_permissions: [SupportedPermission::SIGNIN_NAME])
@granter = create(:user_in_organisation, with_signin_permissions_for: [@application])
@grantee = c... |
github | alphagov/signon | https://github.com/alphagov/signon | test/integration/users/name_change_test.rb | Ruby | mit | 97 | main | 572 | require "test_helper"
class Users::NameChangeTest < ActionDispatch::IntegrationTest
context "when signed in as any kind of admin" do
setup do
@superadmin = create(:superadmin_user)
@user = create(:user, name: "user-name")
end
should "be able to change a normal user's name" do
visit roo... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/expired_not_signed_in_user_deleter_test.rb | Ruby | mit | 97 | main | 1,419 | require "test_helper"
class ExpiredNotSignedInUserDeleterTest < ActiveSupport::TestCase
test "deletes web users who've never signed in and were invited over 90 days ago" do
create(:user).tap(&:invite!)
has_signed_in = create(:user, current_sign_in_at: 1.day.ago).tap(&:invite!)
Timecop.travel(91.days)
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/inactive_users_suspension_reminder_mailing_list_test.rb | Ruby | mit | 97 | main | 1,855 | require "test_helper"
class InactiveUsersSuspensionReminderMailingListTest < ActiveSupport::TestCase
def suspension_reminder_mailing_list
InactiveUsersSuspensionReminderMailingList.new(User::SUSPENSION_THRESHOLD_PERIOD).generate
end
context "generating suspension mailing list" do
setup do
@in1 = ... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/sso_push_error_test.rb | Ruby | mit | 97 | main | 1,671 | require "test_helper"
require "gds_api/base"
class SSOPushErrorTest < ActiveSupport::TestCase
def setup
@user = create(:user)
@application = create(:application, redirect_uri: "https://app.com/callback", with_non_delegated_supported_permissions: %w[user_update_permission])
end
context "rescuing GdsApi::... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/expired_oauth_access_records_deleter_test.rb | Ruby | mit | 97 | main | 5,003 | require "test_helper"
class ExpiredOauthAccessRecordsDeleterTest < ActiveSupport::TestCase
setup do
$stdout.stubs(:write)
end
context "deleting grant records" do
should "delete expired `Doorkeeper::AccessGrant`s" do
user = create(:user)
create(:access_grant, resource_owner_id: user.id, expir... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/signin_permission_granter_test.rb | Ruby | mit | 97 | main | 1,601 | require "test_helper"
class SigninPermissionGranterTest < ActiveSupport::TestCase
setup do
@application_supporting_push_updates = create(:application, supports_push_updates: true)
@application_not_supporting_push_updates = create(:application, supports_push_updates: false)
$stdout.stubs(:puts)
end
s... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/code_verifier_test.rb | Ruby | mit | 97 | main | 784 | require "test_helper"
class CodeVerifierTest < ActiveSupport::TestCase
attr_reader :secret
setup do
@secret = "topsecret"
end
test "#verify" do
verifier = CodeVerifier.new(valid_code, secret)
assert verifier.verify
end
test "#verify when the code contains additional spaces" do
valid_cod... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/roles_test.rb | Ruby | mit | 97 | main | 2,310 | require "test_helper"
class RolesTest < ActiveSupport::TestCase
class Subject
include ActiveModel::Validations
include Roles
attr_accessor :role
end
context "Roles.all" do
should "include all role classes" do
expected_role_classes = [
Roles::Normal,
Roles::Admin,
R... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/inactive_users_suspension_reminder_test.rb | Ruby | mit | 97 | main | 3,063 | require "test_helper"
class InactiveUsersSuspensionReminderTest < ActiveSupport::TestCase
context "sending reminder emails" do
should "send reminder emails to users when 1 day from suspension" do
suspends_in_1_day = create(:user, current_sign_in_at: User::SUSPENSION_THRESHOLD_PERIOD.ago)
mailer = mo... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/user_permission_migrator_test.rb | Ruby | mit | 97 | main | 2,659 | require "test_helper"
class UserPermissionMigrationTest < ActiveSupport::TestCase
setup do
@specialist_publisher = create(:application, name: "Specialist Publisher")
@manuals_publisher = create(:application, name: "Manuals Publisher")
@unrelated_application = create(:application, name: "unrelated applica... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/sso_push_credential_test.rb | Ruby | mit | 97 | main | 4,147 | require "test_helper"
class SSOPushCredentialTest < ActiveSupport::TestCase
setup do
@application = create(:application, with_non_delegated_supported_permissions: %w[user_update_permission])
@user = SSOPushCredential.user
end
context "given an already authorised application" do
setup do
@autho... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/inactive_users_suspender_test.rb | Ruby | mit | 97 | main | 3,538 | require "test_helper"
class InactiveUsersSuspenderTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
test "suspends users who have not logged-in for more than suspension threshold days" do
inactive_user = create(:user, current_sign_in_at: 46.days.ago)
InactiveUsersSuspender.new.suspend
ass... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/organisations_fetcher_test.rb | Ruby | mit | 97 | main | 3,807 | require "test_helper"
require "gds_api/test_helpers/organisations"
class OrganisationsFetcherTest < ActiveSupport::TestCase
include GdsApi::TestHelpers::Organisations
test "it creates new organisations when none exist" do
organisation_slugs = %w[ministry-of-fun tea-agency]
stub_organisations_api_has_organ... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/sso_push_client_test.rb | Ruby | mit | 97 | main | 2,152 | require "test_helper"
class SSOPushClientTest < ActiveSupport::TestCase
def reauth_url(application)
url = URI.parse(application.redirect_uri)
"https://#{url.host}/auth/gds/api/users/#{CGI.escape(@user.uid)}/reauth"
end
def users_url(application)
url = URI.parse(application.redirect_uri)
"https:/... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/user_parameter_sanitiser_test.rb | Ruby | mit | 97 | main | 1,908 | require "test_helper"
class UserParameterSanitiserTest < ActiveSupport::TestCase
context "with Plain Old Ruby Hash for params" do
setup do
permitted_params_by_role = { normal: %i[name email] }
@user_params = { name: "Anne", email: "anne@anne.com" }
@sanitised_params = UserParameterSanitiser.ne... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/organisation_mappings/zendesk_to_signon_test.rb | Ruby | mit | 97 | main | 1,445 | require "test_helper"
class OrganisationMappings::ZendeskToSignonTest < ActiveSupport::TestCase
# Reimplemtation of silence_stream as it was removed in Rails 5
def silence_stream(stream, &_block)
old_stream = stream.dup
stream.reopen(File::NULL)
stream.sync = true
yield
ensure
stream.reopen(... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/data_hygiene/bulk_organisation_updater_test.rb | Ruby | mit | 97 | main | 1,498 | require "test_helper"
class DataHygiene::BulkOrganisationUpdaterTest < ActiveSupport::TestCase
def process(csv_file)
file = Tempfile.new("bulk_update_organisation")
file.write(csv_file)
file.close
begin
DataHygiene::BulkOrganisationUpdater.call(file.path, logger: Rails.logger)
ensure
... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/collectors/global_prometheus_collector_test.rb | Ruby | mit | 97 | main | 932 | require "test_helper"
class GlobalPrometheusCollectorTest < ActiveSupport::TestCase
def setup
@collector = Collectors::GlobalPrometheusCollector.new
@api_user = create(:api_user_with_tokens, token_count: 4)
end
context "#metrics" do
should "list all non-revoked token expiry timestamps for non-retire... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/kubernetes/client_test.rb | Ruby | mit | 97 | main | 2,588 | require "test_helper"
class Kubernetes::ClientTest < ActiveSupport::TestCase
context "#new" do
should "initialise a client with defaults" do
File.stubs(:exist?).with(Kubernetes::Client::CA_FILE)
.returns(false).once
Kubeclient::Client.stubs(:new).with(
Kubernetes::Client::API_SERVER,... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/tasks/data_hygiene_test.rb | Ruby | mit | 97 | main | 1,255 | require "test_helper"
class DataHygieneTaskTest < ActiveSupport::TestCase
setup do
Signon::Application.load_tasks if Rake::Task.tasks.empty?
$stdout.stubs(:write)
end
context "#close_organisation" do
should "mark the organisation as closed" do
organisation = create(:organisation, slug: "depar... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/tasks/permissions_test.rb | Ruby | mit | 97 | main | 10,965 | require "test_helper"
class PermissionsTest < ActiveSupport::TestCase
setup do
Signon::Application.load_tasks if Rake::Task.tasks.empty?
@gds_org = create(:gds_organisation)
@non_gds_org = create(:organisation, name: "Another Department")
$stdout.stubs(:write)
end
teardown do
@task.reenable... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/tasks/access_tokens_test.rb | Ruby | mit | 97 | main | 2,088 | require "test_helper"
class AccessTokensTaskTest < ActiveSupport::TestCase
setup do
Signon::Application.load_tasks if Rake::Task.tasks.empty?
@task = Rake::Task["access_tokens:renew_expiring_internal_tokens"]
@user = create(
:api_user,
email: "test-app@publishing.service.gov.uk",
)
en... |
github | alphagov/signon | https://github.com/alphagov/signon | test/lib/tasks/users_test.rb | Ruby | mit | 97 | main | 3,294 | require "test_helper"
class UsersTaskTest < ActiveSupport::TestCase
setup do
Signon::Application.load_tasks if Rake::Task.tasks.empty?
$stdout.stubs(:write)
@user_types = %i[user superadmin_user admin_user organisation_admin_user super_organisation_admin_user]
end
context "#set_2sv_by_org" do
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.