Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1382 from bgeuken/add_proxy_test
Add tests for check_user action, which also covers the proxy use case
- Loading branch information
Showing
10 changed files
with
64 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require_relative '../../test_helper' | ||
|
||
class Webui::WebuiControllerTest < Webui::IntegrationTest | ||
setup do | ||
@before = CONFIG['proxy_auth_mode'] | ||
# Fake proxy mode | ||
CONFIG['proxy_auth_mode'] = :on | ||
end | ||
|
||
teardown do | ||
CONFIG['proxy_auth_mode'] = @before | ||
end | ||
|
||
def test_check_user_in_proxy | ||
use_js | ||
|
||
# No user set by proxy | ||
visit search_path | ||
page.must_have_text "Log In" | ||
|
||
# Existing OBS user | ||
page.driver.add_header('X_USERNAME', 'tom') | ||
|
||
visit search_path | ||
assert_equal "tom", find('#link-to-user-home').text, "Should log in existing users" | ||
|
||
# New OBS user | ||
page.driver.add_header('X_USERNAME', 'new_user') | ||
page.driver.add_header('X_EMAIL', 'new_user@obs.com') | ||
page.driver.add_header('X_FIRSTNAME', 'Bob') | ||
page.driver.add_header('X_LASTNAME', 'Geldof') | ||
|
||
visit search_path | ||
|
||
user = User.find_by(login: "new_user") | ||
assert user, "Should create a new user" | ||
assert_equal "Bob Geldof", user.realname | ||
assert_equal "new_user@obs.com", user.email | ||
assert_equal "new_user", find('#link-to-user-home').text, "Should log in new user" | ||
end | ||
end |