| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 57ec3c9 commit 03e79c0
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,14 +30,12 @@ def __init__(self): | |||
| 30 | 30 | f'but none found in environment variable {_KAGGLE_USER_SECRETS_TOKEN_ENV_VAR_NAME}') | |
| 31 | 31 | self.headers = { | |
| 32 | 32 | 'Content-type': 'application/json', | |
| 33 | - 'Authorization': f'Bearer {self.jwt_token}', | ||
| 34 | 33 | 'X-Kaggle-Authorization': f'Bearer {self.jwt_token}', | |
| 35 | 34 | } | |
| 36 | 35 | ||
| 37 | 36 | def make_post_request(self, data: dict, endpoint: str, timeout: int = TIMEOUT_SECS) -> dict: | |
| 38 | 37 | url = f'{self.url_base}{endpoint}' | |
| 39 | 38 | request_body = dict(data) | |
| 40 | - request_body['JWE'] = self.jwt_token | ||
| 41 | 39 | req = urllib.request.Request(url, headers=self.headers, data=bytes( | |
| 42 | 40 | json.dumps(request_body), encoding="utf-8")) | |
| 43 | 41 | try: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,10 +85,10 @@ def get_response(self): | |||
| 85 | 85 | msg="Fake server did not receive a Content-Type header from the KaggleDatasets client.") | |
| 86 | 86 | self.assertEqual('application/json', headers.get('Content-Type'), | |
| 87 | 87 | msg="Fake server did not receive an application/json content type header from the KaggleDatasets client.") | |
| 88 | - self.assertIn('Authorization', headers.keys(), | ||
| 89 | - msg="Fake server did not receive an Authorization header from the KaggleDatasets client.") | ||
| 90 | - self.assertEqual(f'Bearer {_TEST_JWT}', headers.get('Authorization'), | ||
| 91 | - msg="Fake server did not receive the right Authorization header from the KaggleDatasets client.") | ||
| 88 | + self.assertIn('X-Kaggle-Authorization', headers.keys(), | ||
| 89 | + msg="Fake server did not receive an X-Kaggle-Authorization header from the KaggleDatasets client.") | ||
| 90 | + self.assertEqual(f'Bearer {_TEST_JWT}', headers.get('X-Kaggle-Authorization'), | ||
| 91 | + msg="Fake server did not receive the right X-Kaggle-Authorization header from the KaggleDatasets client.") | ||
| 92 | 92 | ||
| 93 | 93 | def test_no_token_fails(self): | |
| 94 | 94 | env = EnvironmentVarGuard() | |
@@ -104,7 +104,7 @@ def call_get_gcs_path(): | |||
| 104 | 104 | self.assertEqual(gcs_path, _TPU_GCS_BUCKET) | |
| 105 | 105 | self._test_client(call_get_gcs_path, | |
| 106 | 106 | '/requests/CopyDatasetVersionToKnownGcsBucketRequest', | |
| 107 | - {'MountSlug': None, 'IntegrationType': 2, 'JWE': _TEST_JWT}, | ||
| 107 | + {'MountSlug': None, 'IntegrationType': 2}, | ||
| 108 | 108 | is_tpu=True) | |
| 109 | 109 | ||
| 110 | 110 | def test_get_gcs_path_automl_succeeds(self): | |
@@ -114,7 +114,7 @@ def call_get_gcs_path(): | |||
| 114 | 114 | self.assertEqual(gcs_path, _AUTOML_GCS_BUCKET) | |
| 115 | 115 | self._test_client(call_get_gcs_path, | |
| 116 | 116 | '/requests/CopyDatasetVersionToKnownGcsBucketRequest', | |
| 117 | - {'MountSlug': None, 'IntegrationType': 1, 'JWE': _TEST_JWT}, | ||
| 117 | + {'MountSlug': None, 'IntegrationType': 1}, | ||
| 118 | 118 | is_tpu=False) | |
| 119 | 119 | ||
| 120 | 120 | def test_get_gcs_path_handles_unsuccessful(self): | |
@@ -124,6 +124,6 @@ def call_get_gcs_path(): | |||
| 124 | 124 | gcs_path = client.get_gcs_path() | |
| 125 | 125 | self._test_client(call_get_gcs_path, | |
| 126 | 126 | '/requests/CopyDatasetVersionToKnownGcsBucketRequest', | |
| 127 | - {'MountSlug': None, 'IntegrationType': 2, 'JWE': _TEST_JWT}, | ||
| 127 | + {'MountSlug': None, 'IntegrationType': 2}, | ||
| 128 | 128 | is_tpu=True, | |
| 129 | 129 | success=False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -94,7 +94,7 @@ def call_get_secret(): | |||
| 94 | 94 | secret_response = client.get_secret("secret_label") | |
| 95 | 95 | self.assertEqual(secret_response, secret) | |
| 96 | 96 | self._test_client(call_get_secret, | |
| 97 | - '/requests/GetUserSecretByLabelRequest', {'Label': "secret_label", 'JWE': _TEST_JWT}, | ||
| 97 | + '/requests/GetUserSecretByLabelRequest', {'Label': "secret_label"}, | ||
| 98 | 98 | secret=secret) | |
| 99 | 99 | ||
| 100 | 100 | def test_get_secret_handles_unsuccessful(self): | |
@@ -103,7 +103,7 @@ def call_get_secret(): | |||
| 103 | 103 | with self.assertRaises(BackendError): | |
| 104 | 104 | secret_response = client.get_secret("secret_label") | |
| 105 | 105 | self._test_client(call_get_secret, | |
| 106 | - '/requests/GetUserSecretByLabelRequest', {'Label': "secret_label", 'JWE': _TEST_JWT}, | ||
| 106 | + '/requests/GetUserSecretByLabelRequest', {'Label': "secret_label"}, | ||
| 107 | 107 | success=False) | |
| 108 | 108 | ||
| 109 | 109 | def test_get_secret_validates_label(self): | |
@@ -122,7 +122,7 @@ def call_get_secret(): | |||
| 122 | 122 | secret_response = client.get_gcloud_credential() | |
| 123 | 123 | self.assertEqual(secret_response, secret) | |
| 124 | 124 | self._test_client(call_get_secret, | |
| 125 | - '/requests/GetUserSecretByLabelRequest', {'Label': "__gcloud_sdk_auth__", 'JWE': _TEST_JWT}, | ||
| 125 | + '/requests/GetUserSecretByLabelRequest', {'Label': "__gcloud_sdk_auth__"}, | ||
| 126 | 126 | secret=secret) | |
| 127 | 127 | ||
| 128 | 128 | def test_get_gcloud_secret_handles_unsuccessful(self): | |
@@ -131,7 +131,7 @@ def call_get_secret(): | |||
| 131 | 131 | with self.assertRaises(NotFoundError): | |
| 132 | 132 | secret_response = client.get_gcloud_credential() | |
| 133 | 133 | self._test_client(call_get_secret, | |
| 134 | - '/requests/GetUserSecretByLabelRequest', {'Label': "__gcloud_sdk_auth__", 'JWE': _TEST_JWT}, | ||
| 134 | + '/requests/GetUserSecretByLabelRequest', {'Label': "__gcloud_sdk_auth__"}, | ||
| 135 | 135 | success=False) | |
| 136 | 136 | ||
| 137 | 137 | ||
@@ -150,10 +150,10 @@ def call_get_gcs_access_token(): | |||
| 150 | 150 | secret_response = client._get_gcs_access_token() | |
| 151 | 151 | self.assertEqual(secret_response, (secret, now + timedelta(seconds=3600))) | |
| 152 | 152 | self._test_client(call_get_bigquery_access_token, | |
| 153 | - '/requests/GetUserSecretRequest', {'Target': GcpTarget.BIGQUERY.target, 'JWE': _TEST_JWT}, | ||
| 153 | + '/requests/GetUserSecretRequest', {'Target': GcpTarget.BIGQUERY.target}, | ||
| 154 | 154 | secret=secret) | |
| 155 | 155 | self._test_client(call_get_gcs_access_token, | |
| 156 | - '/requests/GetUserSecretRequest', {'Target': GcpTarget.GCS.target, 'JWE': _TEST_JWT}, | ||
| 156 | + '/requests/GetUserSecretRequest', {'Target': GcpTarget.GCS.target}, | ||
| 157 | 157 | secret=secret) | |
| 158 | 158 | ||
| 159 | 159 | def test_get_access_token_handles_unsuccessful(self): | |
@@ -162,4 +162,4 @@ def call_get_access_token(): | |||
| 162 | 162 | with self.assertRaises(BackendError): | |
| 163 | 163 | client.get_bigquery_access_token() | |
| 164 | 164 | self._test_client(call_get_access_token, | |
| 165 | - '/requests/GetUserSecretRequest', {'Target': GcpTarget.BIGQUERY.target, 'JWE': _TEST_JWT}, success=False) | ||
| 165 | + '/requests/GetUserSecretRequest', {'Target': GcpTarget.BIGQUERY.target}, success=False) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments