Skip to content

Commit

Permalink
Move auth_token_path to config settings instead of as a CONST on the …
Browse files Browse the repository at this point in the history
…mulesoft token client class (#19581)
  • Loading branch information
coope93 authored Nov 25, 2024
1 parent bbe1eab commit 5cf671e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ form_10_10cg:
token_url: ~
client_id: ~
client_secret: ~
auth_token_path: ~
poa:
s3:
aws_access_key_id: my-aws-key-id
Expand Down
7 changes: 5 additions & 2 deletions lib/carma/client/mule_soft_auth_token_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class MuleSoftAuthTokenClient < Common::Client::Base
include Common::Client::Concerns::Monitoring

STATSD_KEY_PREFIX = 'api.carma.mulesoft.auth'
AUTH_TOKEN_PATH = 'oauth2/ause1x1h6Zit9ziQL0j6/v1/token'
GRANT_TYPE = 'client_credentials'
SCOPE = 'DTCWriteResource'

Expand All @@ -19,7 +18,7 @@ class GetAuthTokenError < StandardError; end
def new_bearer_token
with_monitoring do
response = perform(:post,
AUTH_TOKEN_PATH,
auth_token_path,
params,
token_headers,
{ timeout: config.timeout })
Expand Down Expand Up @@ -55,6 +54,10 @@ def client_id
def client_secret
config.settings.client_secret
end

def auth_token_path
config.settings.auth_token_path
end
end
end
end
5 changes: 3 additions & 2 deletions spec/lib/carma/client/mule_soft_auth_token_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
token_url: 'my/token/url',
client_id: 'id',
client_secret: 'secret',
auth_token_path: 'auth/token/path',
timeout:
)
end
Expand Down Expand Up @@ -57,7 +58,7 @@
expect(client).to receive(:perform)
.with(
:post,
CARMA::Client::MuleSoftAuthTokenClient::AUTH_TOKEN_PATH,
config.settings.auth_token_path,
token_params, token_headers, options
)
.and_return(mock_token_response)
Expand All @@ -71,7 +72,7 @@

it 'raises error' do
expect(client).to receive(:perform)
.with(:post, CARMA::Client::MuleSoftAuthTokenClient::AUTH_TOKEN_PATH, token_params, token_headers, options)
.with(:post, config.settings.auth_token_path, token_params, token_headers, options)
.and_return(mock_error_token_response)

expect do
Expand Down

0 comments on commit 5cf671e

Please sign in to comment.