mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 06:56:23 +02:00
fixed zeitwerk load file issue
This commit is contained in:
parent
e0e9c43575
commit
f384520cbf
5 changed files with 72 additions and 69 deletions
|
@ -3,8 +3,8 @@ require 'auth_token/auth_token_decryptor'
|
|||
module Api
|
||||
module V1
|
||||
module AccreditationCenter
|
||||
if Feature.allow_accr_endspoints?
|
||||
class BaseController < ActionController::API
|
||||
class BaseController < ActionController::API
|
||||
if Feature.allow_accr_endspoints?
|
||||
rescue_from ActiveRecord::RecordNotFound, with: :show_not_found_error
|
||||
rescue_from ActiveRecord::RecordInvalid, with: :show_invalid_record_error
|
||||
rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception|
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Repp
|
||||
module V1
|
||||
module Registrar
|
||||
if Feature.allow_accr_endspoints?
|
||||
class AccreditationInfoController < BaseController
|
||||
class AccreditationInfoController < BaseController
|
||||
if Feature.allow_accr_endspoints?
|
||||
api :GET, 'repp/v1/registrar/accreditation/get_info'
|
||||
desc 'check login user and return data'
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
module Repp
|
||||
module V1
|
||||
module Registrar
|
||||
if Feature.allow_accr_endspoints?
|
||||
class AccreditationResultsController < ActionController::API
|
||||
class AccreditationResultsController < ActionController::API
|
||||
if Feature.allow_accr_endspoints?
|
||||
before_action :authenticate_shared_key
|
||||
|
||||
TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze
|
||||
EXPIRE_DEADLINE = 15.minutes.freeze
|
||||
TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze
|
||||
EXPIRE_DEADLINE = 15.minutes.freeze
|
||||
|
||||
api :POST, 'repp/v1/registrar/accreditation/push_results'
|
||||
desc 'added datetime results'
|
||||
|
@ -26,7 +26,6 @@ module Repp
|
|||
user = ApiUser.find_by(username: username)
|
||||
|
||||
raise ActiveRecord::RecordNotFound if user.nil?
|
||||
|
||||
user.accreditation_date = DateTime.current
|
||||
user.accreditation_expire_date = user.accreditation_date + EXPIRE_DEADLINE
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue