mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
REPP: Authentication test
This commit is contained in:
parent
2a136a776f
commit
87dff41a4e
5 changed files with 58 additions and 4 deletions
26
test/integration/repp/v1/base_test.rb
Normal file
26
test/integration/repp/v1/base_test.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1BaseTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@registrant = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@registrant.username}:#{@registrant.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_unauthorized_user_has_no_access
|
||||
get repp_v1_contacts_path
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :unauthorized
|
||||
assert_equal 'Invalid authorization information', response_json[:message]
|
||||
end
|
||||
|
||||
def test_authenticates_valid_user
|
||||
get repp_v1_contacts_path, headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue