mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 22:46:22 +02:00
Added additional tests to REPP API
This commit is contained in:
parent
b505de2f0f
commit
b502c2779e
21 changed files with 796 additions and 7 deletions
39
test/integration/repp/v1/registrar/auth/check_info_test.rb
Normal file
39
test/integration/repp/v1/registrar/auth/check_info_test.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1RegistrarAuthCheckInfoTest < 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_returns_valid_user_auth_values
|
||||
get '/repp/v1/registrar/auth', headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal json[:data][:username], @user.username
|
||||
assert json[:data][:roles].include? 'super'
|
||||
assert_equal json[:data][:registrar_name], 'Best Names'
|
||||
assert_equal json[:data][:balance][:amount].to_f, @user.registrar.cash_account.balance
|
||||
assert json[:data][:abilities].is_a? Hash
|
||||
end
|
||||
|
||||
def test_invalid_user_login
|
||||
token = Base64.encode64("#{@user.username}:0066600")
|
||||
token = "Basic #{token}"
|
||||
|
||||
auth_headers = { 'Authorization' => token }
|
||||
|
||||
get '/repp/v1/registrar/auth', 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