diff options
author | Azul <azul@riseup.net> | 2016-03-31 11:40:44 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-03-31 11:40:44 +0200 |
commit | be5efb57dc9b282a31cf29c9eac27cb5a7e7ac2f (patch) | |
tree | ce8bee7d2fa4007a1db9815e1af001fe44e329c1 /test/support/auth_test_helper.rb | |
parent | 14c9f2ab7cbf410bcd7fdd75b4a1c11417b30bd7 (diff) | |
parent | 48acca107b9bd7a59bacb1449b042eb753e63917 (diff) |
Merge remote-tracking branch 'github/211' into develop
Diffstat (limited to 'test/support/auth_test_helper.rb')
-rw-r--r-- | test/support/auth_test_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/support/auth_test_helper.rb b/test/support/auth_test_helper.rb index 7af3341..acc6076 100644 --- a/test/support/auth_test_helper.rb +++ b/test/support/auth_test_helper.rb @@ -29,6 +29,21 @@ module AuthTestHelper @token.expects(:destroy) if @token end + # authenticate as the api monitor + def monitor_auth(&block) + token_auth(APP_CONFIG['api_tokens']['monitor'], &block) + end + + # authenticate with a token + def token_auth(token_str) + original = request.env['HTTP_AUTHORIZATION'] + request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(token_str) + if block_given? + yield + request.env['HTTP_AUTHORIZATION'] = original + end + end + protected def header_for_token_auth |