diff --git a/app/controllers/api/v1/registrant/auth_controller.rb b/app/controllers/api/v1/registrant/auth_controller.rb new file mode 100644 index 000000000..c137a1286 --- /dev/null +++ b/app/controllers/api/v1/registrant/auth_controller.rb @@ -0,0 +1,19 @@ +require 'rails5_api_controller_backport' + +module Api + module V1 + module Registrant + class AuthController < ActionController::API + def eid + login_params = set_eid_params + + render json: login_params + end + + def set_eid_params + params.permit(:ident, :first_name, :last_name, :country) + end + end + end + end +end diff --git a/config/application.rb b/config/application.rb index 400e72124..1420d3cd3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -36,7 +36,7 @@ module DomainNameRegistry config.i18n.default_locale = :en config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb') - config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')] + # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')] # Autoload all model subdirs config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')] diff --git a/config/routes.rb b/config/routes.rb index 8f50d5587..2bc965a0f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,15 @@ Rails.application.routes.draw do mount Repp::API => '/' + namespace :api do + namespace :v1 do + namespace :registrant do + post 'auth/eid', to: 'auth#eid' + post 'auth/username', to: 'auth#username' + end + end + end + # REGISTRAR ROUTES namespace :registrar do resource :dashboard diff --git a/test/system/api/registrant/registrant_api_authentication_test.rb b/test/system/api/registrant/registrant_api_authentication_test.rb new file mode 100644 index 000000000..5ecd7e08a --- /dev/null +++ b/test/system/api/registrant/registrant_api_authentication_test.rb @@ -0,0 +1,24 @@ +require 'test_helper' + +class RegistrantApiAuthenticationTest < ApplicationSystemTestCase + def setup + super + + end + + def teardown + super + + end + + def test_request_creates_user_when_one_does_not_exist + params = { + ident: "30110100103", + first_name: "Jan", + last_name: "Tamm", + country: "ee", + } + + post '/api/v1/registrant/auth/eid', params + end +end