Skip to content

Commit 52aa189

Browse files
committed
fixed test issue
1 parent 1e73dd8 commit 52aa189

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

spec/services/urn_lists/api_client_spec.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
RSpec.describe UrnLists::ApiClient do
44
describe '#fetch_rows' do
55
before do
6-
stub_request(:post, 'https://login.microsoftonline.com/9f8c0d79-3e87-4cd3-9799-c3443146ea5e/oauth2/v2.0/token')
6+
stub_request(:post, "https://example.com/oauth/token")
7+
.with(
8+
body: {"client_id" => "test_client_id", "client_secret" => "test_client_secret", "grant_type" => "client_credentials", "scope" => "test_scope"},
9+
headers: {
10+
'Accept'=>'*/*',
11+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
12+
'Content-Type'=>'application/x-www-form-urlencoded',
13+
'Host'=>'example.com',
14+
'User-Agent'=>'Ruby'
15+
})
716
.to_return(
8-
status: 200,
17+
status: 200,
918
body: { access_token: 'abc123' }.to_json,
1019
headers: { 'Content-Type' => 'application/json' }
1120
)
@@ -32,6 +41,12 @@
3241
].to_json,
3342
headers: { 'Content-Type' => 'application/json' }
3443
)
44+
45+
allow(ENV).to receive(:fetch).and_call_original
46+
allow(ENV).to receive(:fetch).with('MDM_API_TOKEN_URL').and_return('https://example.com/oauth/token')
47+
allow(ENV).to receive(:fetch).with('MDM_API_CLIENT_ID').and_return('test_client_id')
48+
allow(ENV).to receive(:fetch).with('MDM_API_CLIENT_SECRET').and_return('test_client_secret')
49+
allow(ENV).to receive(:fetch).with('MDM_API_SCOPE').and_return('test_scope')
3550
end
3651

3752
it 'fetches and returns customer data' do

0 commit comments

Comments
 (0)