mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
added test
This commit is contained in:
parent
6e82d8be9e
commit
64cb2c35f3
2 changed files with 34 additions and 1 deletions
33
test/integration/repp/v1/registrar/login_test.rb
Normal file
33
test/integration/repp/v1/registrar/login_test.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1LoginTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_valid_login
|
||||
get '/repp/v1/registrar/login', headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal json[:data][:username], @user.username
|
||||
assert_equal json[:data][:identity_code], @user.identity_code
|
||||
end
|
||||
|
||||
def test_invalid_login
|
||||
token = Base64.encode64("#{@user.username}:0066600")
|
||||
token = "Basic #{token}"
|
||||
|
||||
auth_headers = { 'Authorization' => token }
|
||||
|
||||
get '/repp/v1/registrar/login', headers: auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :unauthorized
|
||||
assert_equal json[:message], 'Invalid authorization information'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue