fixed zeitwerk load file issue

This commit is contained in:
olegphenomenon 2022-09-30 14:21:01 +03:00
parent e0e9c43575
commit f384520cbf
5 changed files with 72 additions and 69 deletions

View file

@ -1,35 +1,37 @@
require 'test_helper'
class ReppV1AccreditationInfoTest < ActionDispatch::IntegrationTest
def setup
@user = users(:api_bestnames)
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
token = "Basic #{token}"
if Feature.allow_accr_endspoints?
def setup
@user = users(:api_bestnames)
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
end
@auth_headers = { 'Authorization' => token }
end
def test_valid_login
get '/repp/v1/registrar/accreditation/get_info', headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
def test_valid_login
get '/repp/v1/registrar/accreditation/get_info', headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
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][:registrar_reg_no], '1234'
end
assert_response :ok
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][:registrar_reg_no], '1234'
end
def test_invalid_login
token = Base64.encode64("#{@user.username}:0066600")
token = "Basic #{token}"
def test_invalid_login
token = Base64.encode64("#{@user.username}:0066600")
token = "Basic #{token}"
auth_headers = { 'Authorization' => token }
auth_headers = { 'Authorization' => token }
get '/repp/v1/registrar/accreditation/get_info', headers: auth_headers
json = JSON.parse(response.body, symbolize_names: true)
get '/repp/v1/registrar/accreditation/get_info', headers: auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :unauthorized
assert_equal json[:message], 'Invalid authorization information'
assert_response :unauthorized
assert_equal json[:message], 'Invalid authorization information'
end
end
end

View file

@ -1,52 +1,54 @@
require 'test_helper'
class ReppV1AccreditationResultsTest < ActionDispatch::IntegrationTest
TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze
if Feature.allow_accr_endspoints?
TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze
def setup
@user = users(:api_bestnames)
def setup
@user = users(:api_bestnames)
token = "Basic #{TEMPORARY_SECRET_KEY}"
token = "Basic #{TEMPORARY_SECRET_KEY}"
@auth_headers = { 'Authorization' => token }
end
@auth_headers = { 'Authorization' => token }
end
def test_should_return_valid_response
post '/repp/v1/registrar/accreditation/push_results',
headers: @auth_headers,
params: {accreditation_result: {username: @user.username, result: true} }
json = JSON.parse(response.body, symbolize_names: true)
def test_should_return_valid_response
post '/repp/v1/registrar/accreditation/push_results',
headers: @auth_headers,
params: {accreditation_result: {username: @user.username, result: true} }
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
assert_emails 2
assert_equal json[:data][:user][:username], @user.username
assert_equal json[:data][:result], "true"
assert_equal json[:data][:message], "Accreditation info successfully added"
end
assert_response :ok
assert_emails 2
assert_equal json[:data][:user][:username], @user.username
assert_equal json[:data][:result], "true"
assert_equal json[:data][:message], "Accreditation info successfully added"
end
def test_should_return_valid_response_invalid_authorization
post '/repp/v1/registrar/accreditation/push_results',
headers: { 'Authorization' => 'Basic temporary-secret-ke'},
params: {accreditation_result: {username: @user.username, result: true} }
json = JSON.parse(response.body, symbolize_names: true)
def test_should_return_valid_response_invalid_authorization
post '/repp/v1/registrar/accreditation/push_results',
headers: { 'Authorization' => 'Basic temporary-secret-ke'},
params: {accreditation_result: {username: @user.username, result: true} }
json = JSON.parse(response.body, symbolize_names: true)
assert_response :unauthorized
assert_response :unauthorized
assert_emails 0
assert_equal json[:code], 2202
assert_equal json[:message], 'Invalid authorization information'
end
assert_emails 0
assert_equal json[:code], 2202
assert_equal json[:message], 'Invalid authorization information'
end
def test_should_return_valid_response_record_exception
post '/repp/v1/registrar/accreditation/push_results',
headers: @auth_headers,
params: {accreditation_result: { username: "chungachanga", result: true} }
json = JSON.parse(response.body, symbolize_names: true)
def test_should_return_valid_response_record_exception
post '/repp/v1/registrar/accreditation/push_results',
headers: @auth_headers,
params: {accreditation_result: { username: "chungachanga", result: true} }
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
assert_response :ok
assert_emails 0
assert_equal json[:code], 2303
assert_equal json[:message], "Object 'chungachanga' does not exist"
assert_emails 0
assert_equal json[:code], 2303
assert_equal json[:message], "Object 'chungachanga' does not exist"
end
end
end