require 'test_helper'

class AuthenticationTest < ActionDispatch::IntegrationTest

  setup do
    ENV['GDS_SSO_MOCK_INVALID'] = '1'
  end

  test "should use GDS SSO to authenticate" do
    get admin_people_path
    assert_redirected_to "/auth/gds"
  end

  test "should allow access when already logged in" do
    login_as_admin
    get admin_people_path
    assert_response :success
  end
end
require 'test_helper'

class AuthenticationTest < ActionDispatch::IntegrationTest

  setup do
    User.delete_all
    ENV['GDS_SSO_MOCK_INVALID'] = '1'
  end

  test "should use GDS SSO to authenticate" do
    get admin_people_path
    assert_redirected_to "/auth/gds"
  end

  test "should allow access when already logged in" do
    login_as_admin
    get admin_people_path
    assert_response :success
  end
end
Fix test failure due to test interference
Fix test failure due to test interference

The test interference is due to some users existing in the test database
which were created by previous tests. The existence of users in the
database allows the 'mock' authentication strategy to succeed (which
logs in the first user in the DB).

This is a hacky fix, I think that the correct fix would be to change the
logic around GDS_SSO_MOCK_INVALID in the GDS-SSO gem. However, I'm not
confident about the intention/usage of this flag.
