Skip to content

Commit

Permalink
adds unit test to ensure that cloud is injected into request
Browse files Browse the repository at this point in the history
  • Loading branch information
johns31459 committed Jul 3, 2024
1 parent 0d9d7e7 commit e57e31a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/crowdstrike/foundry/function/test_falconpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import unittest
from unittest.mock import patch
from crowdstrike.foundry.function.context import ctx_request
from crowdstrike.foundry.function.falconpy import falcon_client
from crowdstrike.foundry.function.model import Request
from crowdstrike.foundry.function.falconpy import falcon_client
from crowdstrike.foundry.function.model import Request
from falconpy import Hosts

if __name__ == '__main__':
Expand Down Expand Up @@ -54,3 +54,14 @@ def test_request_with_access_token_and_non_default_cloud_returns_prepared_client
self.assertIsInstance(client, Hosts)
self.assertEqual('Bearer foo', client.headers.get('Authorization'))
self.assertEqual(t['expected'], client.base_url)

def test_request_inserts_cloud_into_request(self):
with patch.dict(os.environ, {'CS_CLOUD': 'us-gov-1'}, clear=True):
ctx_request.set(Request(access_token='foo'))
client = falcon_client(Hosts)

self.assertIsInstance(client, Hosts)
self.assertEqual('Bearer foo', client.headers.get('Authorization'))
self.assertEqual('https://api.laggar.gcw.crowdstrike.com', client.base_url)
r = ctx_request.get()
self.assertEqual('usgov1', r.cloud)

0 comments on commit e57e31a

Please sign in to comment.