-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add data_access_admin_group_name to set up request (#4385)
- Loading branch information
1 parent
868baf9
commit 0b7895a
Showing
4 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,20 +197,22 @@ def test_create_origin_trial__no_api_key( | |
# POST request should not be executed with no API key. | ||
mock_requests_post.assert_not_called() | ||
|
||
@mock.patch('framework.secrets.get_ot_data_access_admin_group') | ||
@mock.patch('framework.secrets.get_ot_api_key') | ||
@mock.patch('framework.origin_trials_client._get_ot_access_token') | ||
@mock.patch('framework.origin_trials_client._get_trial_end_time') | ||
@mock.patch('requests.post') | ||
def test_create_origin_trial__with_api_key( | ||
self, mock_requests_post, mock_get_trial_end_time, | ||
mock_get_ot_access_token, mock_api_key_get): | ||
mock_get_ot_access_token, mock_api_key_get, mock_get_admin_group): | ||
"""If an API key is available, POST should create trial and return true.""" | ||
mock_requests_post.return_value = mock.MagicMock( | ||
status_code=200, json=lambda : ( | ||
{'trial': {'id': -1234567890}, 'should_retry': False})) | ||
mock_get_trial_end_time.return_value = 111222333 | ||
mock_get_ot_access_token.return_value = 'access_token' | ||
mock_api_key_get.return_value = 'api_key_value' | ||
mock_get_admin_group.return_value = 'test-group-123' | ||
|
||
ot_id, error_text = origin_trials_client.create_origin_trial(self.ot_stage) | ||
self.assertEqual(ot_id, '-1234567890') | ||
|
@@ -249,6 +251,8 @@ def test_create_origin_trial__with_api_key( | |
# Only unique @google.com emails should be sent as contacts. | ||
self.assertCountEqual(['[email protected]', '[email protected]'], | ||
set_up_trial_json['trial_contacts']) | ||
self.assertEqual('test-group-123', | ||
set_up_trial_json['data_access_admin_group_name']) | ||
self.assertEqual(-1234567890, set_up_trial_json['trial_id']) | ||
|
||
@mock.patch('framework.secrets.get_ot_api_key') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,11 @@ def get_flask_template_path() -> str: | |
# Origin trials API URL | ||
OT_URL = 'https://origintrials-staging.corp.google.com/origintrials/' | ||
OT_API_URL = 'https://staging-chromeorigintrials-pa.sandbox.googleapis.com' | ||
OT_API_KEY: str|None = None # Value is set later when request is needed. | ||
|
||
# Values are set later when request is needed. | ||
OT_API_KEY: str|None = None | ||
OT_DATA_ACCESS_ADMIN_GROUP_NAME: str|None = None | ||
|
||
# Dummy data for local OT support emails. | ||
DEV_MODE_OT_SUPPORT_EMAILS = '[email protected],[email protected]' | ||
|
||
|