Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into k8s #16384

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config/betamocks/services_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
:path: <%= "/#{Settings.ask_va_api.crm_api.veis_api_path}/ping" %>
:file_path: "/ask_va/dynamics_api"
:response_delay: 15
- :method: :get
:path: "/veis/api/btsss/travelclaim/api/v1/Sample/ping"
:file_path: "/travel_pay/ping/default"
:response_delay: 0.3
- :method: :get
:path: "/veis/api/btsss/travelclaim/api/v1/Sample/authorized-ping"
:file_path: "/travel_pay/ping/default"
:response_delay: 0.3
- :method: :post
:path: "/veis/api/btsss/travelclaim/api/v1/Auth/access-token"
:file_path: "/travel_pay/token/default"
:response_delay: 0.3
- :method: :post
:path: <%= "/#{Settings.ask_va_api.crm_api.veis_api_path}/inquiries/new" %>
:file_path: "/ask_va/crm_api/post_inquiries/default"
Expand All @@ -22,6 +34,10 @@
:path: <%= "/#{Settings.ask_va_api.crm_api.tenant_id}/oauth2/v2.0/token" %>
:file_path: "/ask_va/token/default"
:response_delay: 0.3
- :method: :post
:path: <%= "/#{Settings.travel_pay.veis.tenant_id}/oauth2/token" %>
:file_path: "/travel_pay/token/default"
:response_delay: 0.3

- :name: 'carma'
:base_uri: <%= "#{URI(Settings['salesforce-carma'].url).host}:#{URI(Settings['salesforce-carma'].url).port}" %>
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,7 @@ brd:


travel_pay:
mock: true
veis:
client_id: ~
client_secret: ~
Expand Down
460 changes: 237 additions & 223 deletions modules/simple_forms_api/spec/requests/v1/uploads_spec.rb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def after_logger
logger.info('travel-pay') { Utils::Logger.build(self).after }
end

def authorize
auth_header = request.headers['Authorization']
raise_unauthorized('Missing Authorization header') if auth_header.nil?
raise_unauthorized('Authorization header missing Bearer token') unless auth_header.start_with?('Bearer ')
end

def raise_unauthorized(detail)
raise Common::Exceptions::Unauthorized.new(detail:)
end

# Blocks requests from being handled if feature flag is disabled
def block_if_flag_disabled
unless Flipper.enabled?(:travel_pay_power_switch, @current_user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

module TravelPay
class ClaimsController < ApplicationController
before_action :authorize

def index
veis_token = client.request_veis_token

# Non-intuitive Ruby behavior: #split splits a string on space by default
vagov_token = request.headers['Authorization'].split[1]
btsss_token = client.request_btsss_token(veis_token, vagov_token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module TravelPay
class PingsController < ApplicationController
before_action :authorize, only: [:authorized_ping]

def ping
veis_token = client.request_veis_token

Expand Down
6 changes: 3 additions & 3 deletions modules/travel_pay/app/services/travel_pay/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def connection(server_url:)
Faraday.new(url: server_url) do |conn|
conn.use :breakers
conn.response :raise_error, error_prefix: service_name, include_request: true
conn.response :betamocks if use_fakes?
conn.response :betamocks if mock_enabled?
conn.response :json
conn.request :json

Expand All @@ -123,8 +123,8 @@ def connection(server_url:)
##
# Syntactic sugar for determining if the client should use
# fake api responses or actually connect to the BTSSS API
def use_fakes?
Settings.useFakes
def mock_enabled?
Settings.travel_pay.mock
end
end
end
Loading