dq-export-connector 0.1.0.dev11__tar.gz → 0.1.0.dev12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/PKG-INFO +1 -1
  2. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/_models/export_connector_credentials.py +20 -34
  3. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/bucket/export.py +3 -3
  4. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/bucket/store.py +13 -13
  5. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/bucket/validate.py +3 -3
  6. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/redact.py +5 -4
  7. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/runner.py +1 -1
  8. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/pyproject.toml +1 -1
  9. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/tests/test_live_buckets.py +11 -11
  10. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/tests/test_redact.py +2 -2
  11. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/tests/test_runner.py +1 -1
  12. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/tests/test_store.py +11 -11
  13. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/uv.lock +1 -1
  14. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/.gitignore +0 -0
  15. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/.python-version +0 -0
  16. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/README.md +0 -0
  17. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/__init__.py +0 -0
  18. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/_models/__init__.py +0 -0
  19. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/_models/bucket_validation_result.py +0 -0
  20. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/_models/export_report.py +0 -0
  21. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/_models/export_worker_config.py +0 -0
  22. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/bucket/__init__.py +0 -0
  23. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/bucket/datasets.py +0 -0
  24. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/bucket/paths.py +0 -0
  25. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/bucket/upload.py +0 -0
  26. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/errors.py +0 -0
  27. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/log.py +0 -0
  28. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/dq_export_connector/report.py +0 -0
  29. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/scripts/codegen-models.sh +0 -0
  30. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/tests/test_models_are_current.py +0 -0
  31. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/tests/test_paths.py +0 -0
  32. {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev12}/tests/test_upload.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: dq-export-connector
3
- Version: 0.1.0.dev11
3
+ Version: 0.1.0.dev12
4
4
  Summary: Worker logic for the Export Connector DCR.
5
5
  Author: Decentriq
6
6
  Requires-Python: >=3.10
@@ -3,28 +3,21 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Annotated
6
+ from typing import Annotated, Literal
7
7
 
8
8
  from pydantic import BaseModel, ConfigDict, Field, RootModel
9
9
 
10
10
 
11
- class S3(BaseModel):
11
+ class BucketExportCredentials1(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
15
15
  access_key: Annotated[str, Field(alias='accessKey')]
16
16
  secret_key: Annotated[str, Field(alias='secretKey')]
17
+ type: Literal['s3']
17
18
 
18
19
 
19
- class BucketCredentials1(BaseModel):
20
- model_config = ConfigDict(
21
- extra='forbid',
22
- populate_by_name=True,
23
- )
24
- s3: S3
25
-
26
-
27
- class AzureBlob(BaseModel):
20
+ class BucketExportCredentials2(BaseModel):
28
21
  model_config = ConfigDict(
29
22
  populate_by_name=True,
30
23
  )
@@ -32,46 +25,39 @@ class AzureBlob(BaseModel):
32
25
  str,
33
26
  Field(
34
27
  alias='sasToken',
35
- description='A container SAS token — the scoped, expiring grant Azure recommends\nover an account key. Only the grant: the account and container it\napplies to are pinned by the signed `BucketConnection`, so rotating\nthe token can never repoint the connector.',
28
+ description='A container SAS token. Only the grant: the account and container\nit applies to are pinned by the signed `BucketConnection`.',
36
29
  ),
37
30
  ]
31
+ type: Literal['azureBlob']
38
32
 
39
33
 
40
- class BucketCredentials2(BaseModel):
41
- model_config = ConfigDict(
42
- extra='forbid',
43
- populate_by_name=True,
44
- )
45
- azure_blob: Annotated[AzureBlob, Field(alias='azureBlob')]
46
-
47
-
48
- class Gcs(BaseModel):
34
+ class BucketExportCredentials3(BaseModel):
49
35
  model_config = ConfigDict(
50
36
  populate_by_name=True,
51
37
  )
52
38
  service_account_json: Annotated[str, Field(alias='serviceAccountJson')]
39
+ type: Literal['gcs']
53
40
 
54
41
 
55
- class BucketCredentials3(BaseModel):
56
- model_config = ConfigDict(
57
- extra='forbid',
58
- populate_by_name=True,
59
- )
60
- gcs: Gcs
61
-
62
-
63
- class BucketCredentials(
64
- RootModel[BucketCredentials1 | BucketCredentials2 | BucketCredentials3]
42
+ class BucketExportCredentials(
43
+ RootModel[
44
+ BucketExportCredentials1 | BucketExportCredentials2 | BucketExportCredentials3
45
+ ]
65
46
  ):
66
- root: BucketCredentials1 | BucketCredentials2 | BucketCredentials3
47
+ root: Annotated[
48
+ BucketExportCredentials1 | BucketExportCredentials2 | BucketExportCredentials3,
49
+ Field(
50
+ description='The credentials of a Bucket connection, keyed by Bucket Provider like\n[`BucketConnection`]. Secret leaf fields are `Secret`-wrapped so they mask\nin a `redacted()` view but serialize transparently everywhere else.'
51
+ ),
52
+ ]
67
53
 
68
54
 
69
55
  class ExportConnectorCredentials1(BaseModel):
70
56
  model_config = ConfigDict(
71
- extra='forbid',
72
57
  populate_by_name=True,
73
58
  )
74
- bucket: BucketCredentials
59
+ credentials: BucketExportCredentials
60
+ type: Literal['bucket']
75
61
 
76
62
 
77
63
  class ExportConnectorCredentials(RootModel[ExportConnectorCredentials1]):
@@ -12,7 +12,7 @@ from datetime import datetime
12
12
  from pathlib import Path
13
13
  from typing import Any
14
14
 
15
- from dq_export_connector._models.export_connector_credentials import BucketCredentials
15
+ from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
16
16
  from dq_export_connector._models.export_report import BucketConnection as ReceiptConnection
17
17
  from dq_export_connector._models.export_report import (
18
18
  BucketInputReceipt,
@@ -33,10 +33,10 @@ from dq_export_connector.report import ReportBuilder
33
33
  def export(
34
34
  connector: ExportConnectorKind1,
35
35
  policies: list[ProvisionedPolicy],
36
- credentials: BucketCredentials,
36
+ credentials: BucketExportCredentials,
37
37
  inputs_dir: Path,
38
38
  now: datetime,
39
- build_store: Callable[[Any, BucketCredentials], Any],
39
+ build_store: Callable[[Any, BucketExportCredentials], Any],
40
40
  report: ReportBuilder,
41
41
  ) -> None:
42
42
  export_prefix = fill_date_tokens(connector.export_prefix, now) if connector.export_prefix else None
@@ -12,10 +12,10 @@ import obstore.exceptions
12
12
  from obstore.store import AzureStore, GCSStore, S3Store
13
13
 
14
14
  from dq_export_connector._models.export_connector_credentials import (
15
- BucketCredentials,
16
- BucketCredentials1,
17
- BucketCredentials2,
18
- BucketCredentials3,
15
+ BucketExportCredentials,
16
+ BucketExportCredentials1,
17
+ BucketExportCredentials2,
18
+ BucketExportCredentials3,
19
19
  )
20
20
  from dq_export_connector._models.export_worker_config import (
21
21
  BucketConnection,
@@ -181,7 +181,7 @@ _CREDENTIAL_PARSE_ERRORS = (
181
181
  _ECHOED_VALUE = re.compile(r'"(?:[^"\\]|\\.)*"|`(?![A-Za-z_][A-Za-z0-9_]*`)[^`]*`')
182
182
 
183
183
 
184
- def build_store(connection: BucketConnection, credentials: BucketCredentials) -> Any:
184
+ def build_store(connection: BucketConnection, credentials: BucketExportCredentials) -> Any:
185
185
  """obstore parses the credentials here, so a malformed GCS key or Azure SAS
186
186
  token fails before any request, as does an address no URL can hold, such as
187
187
  an Azure account name with a space."""
@@ -199,30 +199,30 @@ def build_store(connection: BucketConnection, credentials: BucketCredentials) ->
199
199
  ) from error
200
200
 
201
201
 
202
- def _store(connection: BucketConnection, credentials: BucketCredentials) -> Any:
202
+ def _store(connection: BucketConnection, credentials: BucketExportCredentials) -> Any:
203
203
  """ddc pins the provider pairing, so a mismatch here is a bug."""
204
204
  match (connection.root, credentials.root):
205
- case (BucketConnection1() as s3, BucketCredentials1() as s3_credentials):
205
+ case (BucketConnection1() as s3, BucketExportCredentials1() as s3_credentials):
206
206
  return S3Store(
207
207
  bucket=s3.bucket,
208
208
  region=s3.region,
209
- access_key_id=_checked_s3_access_key(s3_credentials.s3.access_key),
210
- secret_access_key=s3_credentials.s3.secret_key,
209
+ access_key_id=_checked_s3_access_key(s3_credentials.access_key),
210
+ secret_access_key=s3_credentials.secret_key,
211
211
  retry_config=RETRY_CONFIG,
212
212
  client_options=CLIENT_CONFIG,
213
213
  )
214
- case (BucketConnection2() as azure, BucketCredentials2() as azure_credentials):
214
+ case (BucketConnection2() as azure, BucketExportCredentials2() as azure_credentials):
215
215
  return AzureStore(
216
216
  container_name=azure.container,
217
217
  account_name=azure.account_name,
218
- sas_key=_normalize_azure_sas_token(azure_credentials.azure_blob.sas_token),
218
+ sas_key=_normalize_azure_sas_token(azure_credentials.sas_token),
219
219
  retry_config=RETRY_CONFIG,
220
220
  client_options=CLIENT_CONFIG,
221
221
  )
222
- case (BucketConnection3() as gcs, BucketCredentials3() as gcs_credentials):
222
+ case (BucketConnection3() as gcs, BucketExportCredentials3() as gcs_credentials):
223
223
  return GCSStore(
224
224
  bucket=gcs.bucket,
225
- service_account_key=gcs_credentials.gcs.service_account_json,
225
+ service_account_key=gcs_credentials.service_account_json,
226
226
  retry_config=RETRY_CONFIG,
227
227
  client_options=CLIENT_CONFIG,
228
228
  )
@@ -10,7 +10,7 @@ from typing import Any
10
10
 
11
11
  import obstore
12
12
 
13
- from dq_export_connector._models.export_connector_credentials import BucketCredentials
13
+ from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
14
14
  from dq_export_connector._models.export_worker_config import BucketConnection
15
15
  from dq_export_connector.bucket.paths import join_key
16
16
  from dq_export_connector.bucket.store import StorageError, classify_error, failure_sentence, location, storage_call
@@ -27,8 +27,8 @@ def probe_key(path_prefix: str | None) -> str:
27
27
 
28
28
  def validate_connection(
29
29
  connection: BucketConnection,
30
- credentials: BucketCredentials,
31
- build_store: Callable[[BucketConnection, BucketCredentials], Any],
30
+ credentials: BucketExportCredentials,
31
+ build_store: Callable[[BucketConnection, BucketExportCredentials], Any],
32
32
  report: ReportBuilder,
33
33
  ) -> None:
34
34
  logger.info("Connection test started: provider %s", connection.root.type)
@@ -1,8 +1,8 @@
1
1
  """Keeps the sealed half out of everything the worker writes.
2
2
 
3
3
  Log lines reach Decentriq-readable platform logs, and result messages reach
4
- api-platform in plaintext. Every string value of the credentials is masked, so a
5
- new credential field needs no change here. URL query strings are masked too,
4
+ api-platform in plaintext. Every string value of the credentials but the `type`
5
+ tags is masked, so a new credential field needs no change here. URL query strings are masked too,
6
6
  since storage clients put tokens there, such as an Azure SAS token.
7
7
  """
8
8
 
@@ -20,9 +20,10 @@ _URL_QUERY = re.compile(r"(?P<url>[a-zA-Z][a-zA-Z0-9+.-]*://[^\s?#\"'<>]+)\?[^\s
20
20
 
21
21
  def sealed_values(value: Any) -> list[str]:
22
22
  """Every string in a JSON value, including those inside strings that are
23
- themselves JSON, such as a GCS service account key."""
23
+ themselves JSON, such as a GCS service account key. The `type` tags of
24
+ the credentials, such as `s3`, are not secret."""
24
25
  if isinstance(value, dict):
25
- return [found for item in value.values() for found in sealed_values(item)]
26
+ return [found for key, item in value.items() if key != "type" for found in sealed_values(item)]
26
27
  if isinstance(value, list):
27
28
  return [found for item in value for found in sealed_values(item)]
28
29
  if isinstance(value, str):
@@ -81,7 +81,7 @@ def run(
81
81
  build_store = build_store or store.build_store
82
82
  logger.info("dq-export-connector %s", version("dq-export-connector"))
83
83
  connector = config.connector.root
84
- bucket_credentials = credentials.root.bucket
84
+ bucket_credentials = credentials.root.credentials
85
85
  report = ReportBuilder()
86
86
  match config.action.root:
87
87
  case ExportConnectorDcrComputeAction1():
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dq-export-connector"
3
- version = "0.1.0.dev11"
3
+ version = "0.1.0.dev12"
4
4
  description = "Worker logic for the Export Connector DCR."
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Decentriq" }]
@@ -50,19 +50,19 @@ def _s3(path_prefix: str) -> tuple[dict[str, Any], dict[str, Any]]:
50
50
  "bucket": "decentriq-integration-tests",
51
51
  "pathPrefix": path_prefix,
52
52
  }
53
- return connection, {"bucket": {"s3": {"accessKey": access_key, "secretKey": secret_key}}}
53
+ return connection, {"type": "bucket", "credentials": {"type": "s3", "accessKey": access_key, "secretKey": secret_key}}
54
54
 
55
55
 
56
56
  def _azure(path_prefix: str) -> tuple[dict[str, Any], dict[str, Any]]:
57
57
  account, container, token = _require_env("AZURE_STORAGE_ACCOUNT", "AZURE_STORAGE_CONTAINER", "AZURE_SAS_TOKEN")
58
58
  connection = {"type": "azureBlob", "accountName": account, "container": container, "pathPrefix": path_prefix}
59
- return connection, {"bucket": {"azureBlob": {"sasToken": token}}}
59
+ return connection, {"type": "bucket", "credentials": {"type": "azureBlob", "sasToken": token}}
60
60
 
61
61
 
62
62
  def _gcs(path_prefix: str) -> tuple[dict[str, Any], dict[str, Any]]:
63
63
  (service_account_json,) = _require_env("GCS_SERVICE_ACCOUNT_CREDENTIALS")
64
64
  connection = {"type": "gcs", "bucket": "bucket-test-import-1", "pathPrefix": path_prefix}
65
- return connection, {"bucket": {"gcs": {"serviceAccountJson": service_account_json}}}
65
+ return connection, {"type": "bucket", "credentials": {"type": "gcs", "serviceAccountJson": service_account_json}}
66
66
 
67
67
 
68
68
  @pytest.fixture(params=[_s3, _azure, _gcs], ids=["s3", "azure", "gcs"])
@@ -116,7 +116,7 @@ def test_an_export_lands_in_the_bucket(tmp_path: Path, provider: tuple[dict[str,
116
116
  report = json.loads((output / runner.REPORT_FILE).read_text())
117
117
  store = build_store(
118
118
  BucketConnection.model_validate(connection),
119
- ExportConnectorCredentials.model_validate(credentials).root.bucket,
119
+ ExportConnectorCredentials.model_validate(credentials).root.credentials,
120
120
  )
121
121
  try:
122
122
  written = {
@@ -141,10 +141,10 @@ def _write_error_code(tmp_path: Path, name: str, connection: dict[str, Any], cre
141
141
 
142
142
  def test_s3_failures_are_classified(tmp_path: Path) -> None:
143
143
  connection, credentials = _s3("dq-export-connector-live-tests")
144
- keys = credentials["bucket"]["s3"]
144
+ keys = credentials["credentials"]
145
145
  cases = {
146
- "secret": (connection, {"bucket": {"s3": {**keys, "secretKey": "x" * 40}}}),
147
- "access": (connection, {"bucket": {"s3": {**keys, "accessKey": "AKIAAAAAAAAAAAAAAAAA"}}}),
146
+ "secret": (connection, {"type": "bucket", "credentials": {"type": "s3", **keys, "secretKey": "x" * 40}}),
147
+ "access": (connection, {"type": "bucket", "credentials": {"type": "s3", **keys, "accessKey": "AKIAAAAAAAAAAAAAAAAA"}}),
148
148
  "bucket": ({**connection, "bucket": f"dq-no-such-bucket-{uuid.uuid4().hex}"}, credentials),
149
149
  "region": ({**connection, "region": "eu-central-1"}, credentials),
150
150
  }
@@ -160,10 +160,10 @@ def test_s3_failures_are_classified(tmp_path: Path) -> None:
160
160
 
161
161
  def test_azure_failures_are_classified(tmp_path: Path) -> None:
162
162
  connection, credentials = _azure("dq-export-connector-live-tests")
163
- token = credentials["bucket"]["azureBlob"]["sasToken"]
163
+ token = credentials["credentials"]["sasToken"]
164
164
  signature = token[token.index("sig=") :].split("&")[0]
165
165
  cases = {
166
- "signature": (connection, {"bucket": {"azureBlob": {"sasToken": token.replace(signature, "sig=AAAA")}}}),
166
+ "signature": (connection, {"type": "bucket", "credentials": {"type": "azureBlob", "sasToken": token.replace(signature, "sig=AAAA")}}),
167
167
  "container": ({**connection, "container": f"no-such-{uuid.uuid4().hex[:12]}"}, credentials),
168
168
  }
169
169
  for name in cases:
@@ -176,10 +176,10 @@ def test_azure_failures_are_classified(tmp_path: Path) -> None:
176
176
 
177
177
  def test_gcs_failures_are_classified(tmp_path: Path) -> None:
178
178
  connection, credentials = _gcs("dq-export-connector-live-tests")
179
- account = json.loads(credentials["bucket"]["gcs"]["serviceAccountJson"])
179
+ account = json.loads(credentials["credentials"]["serviceAccountJson"])
180
180
  unknown = {**account, "client_email": "nobody@" + account["client_email"].split("@")[1]}
181
181
  cases = {
182
- "account": (connection, {"bucket": {"gcs": {"serviceAccountJson": json.dumps(unknown)}}}),
182
+ "account": (connection, {"type": "bucket", "credentials": {"type": "gcs", "serviceAccountJson": json.dumps(unknown)}}),
183
183
  "bucket": ({**connection, "bucket": f"dq-no-such-bucket-{uuid.uuid4().hex}"}, credentials),
184
184
  }
185
185
  for name in cases:
@@ -5,13 +5,13 @@ from dq_export_connector.redact import Redactor, sealed_values
5
5
 
6
6
  def test_every_value_of_the_sealed_half_is_found_including_inside_json_strings():
7
7
  service_account = json.dumps({"private_key": "-----BEGIN PRIVATE KEY-----\nabc\n", "client_email": "x@y.iam"})
8
- credentials = {"bucket": {"gcs": {"serviceAccountJson": service_account}}}
8
+ credentials = {"type": "bucket", "credentials": {"type": "gcs", "serviceAccountJson": service_account}}
9
9
  assert sealed_values(credentials) == [service_account, "-----BEGIN PRIVATE KEY-----\nabc\n", "x@y.iam"]
10
10
 
11
11
 
12
12
  def test_an_azure_error_carrying_the_sas_token_is_masked():
13
13
  sas_token = "sv=2024-01-01&ss=b&sig=Zm9vYmFy%3D"
14
- redactor = Redactor(sealed_values({"bucket": {"azureBlob": {"sasToken": sas_token}}}))
14
+ redactor = Redactor(sealed_values({"type": "bucket", "credentials": {"type": "azureBlob", "sasToken": sas_token}}))
15
15
  error = (
16
16
  "Generic MicrosoftAzure error: Error performing PUT "
17
17
  f"https://acme.blob.core.windows.net/exports/seg_a/data?{sas_token}&comp=block in 1.2s: "
@@ -20,7 +20,7 @@ from dq_export_connector.bucket.upload import MIN_PART_SIZE
20
20
  from dq_export_connector.errors import MAX_MESSAGE_LENGTH
21
21
 
22
22
  SECRET_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
23
- CREDENTIALS = {"bucket": {"s3": {"accessKey": "AKIAEXAMPLE", "secretKey": SECRET_KEY}}}
23
+ CREDENTIALS = {"type": "bucket", "credentials": {"type": "s3", "accessKey": "AKIAEXAMPLE", "secretKey": SECRET_KEY}}
24
24
 
25
25
 
26
26
  def _config(action, inputs, export_prefix=None):
@@ -7,7 +7,7 @@ import obstore
7
7
  import obstore.exceptions
8
8
  from obstore.store import S3Store
9
9
 
10
- from dq_export_connector._models.export_connector_credentials import BucketCredentials
10
+ from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
11
11
  from dq_export_connector._models.export_worker_config import BucketConnection
12
12
  from dq_export_connector.bucket.store import build_store, classify_error, describe
13
13
  from dq_export_connector.errors import ErrorCode, ExportConnectorError
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
18
18
 
19
19
  def _build_error(connection, credentials):
20
20
  try:
21
- build_store(BucketConnection.model_validate(connection), BucketCredentials.model_validate(credentials))
21
+ build_store(BucketConnection.model_validate(connection), BucketExportCredentials.model_validate(credentials))
22
22
  except ExportConnectorError as error:
23
23
  return error.code, error.message
24
24
  return None
@@ -34,12 +34,12 @@ def test_malformed_credentials_are_invalid_before_any_request():
34
34
  " file: "
35
35
  )
36
36
  assert [
37
- _build_error(gcs, {"gcs": {"serviceAccountJson": "not json"}}),
38
- _build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps({"private_key": 5})}}),
39
- _build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps({"client_email": "a@b"})}}),
40
- _build_error(azure, {"azureBlob": {"sasToken": "garbage"}}),
41
- _build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps({**service_account, "private_key": "not a pem"})}}),
42
- _build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps({**service_account, "private_key": bad_key})}}),
37
+ _build_error(gcs, {"type": "gcs", "serviceAccountJson": "not json"}),
38
+ _build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({"private_key": 5})}),
39
+ _build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({"client_email": "a@b"})}),
40
+ _build_error(azure, {"type": "azureBlob", "sasToken": "garbage"}),
41
+ _build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({**service_account, "private_key": "not a pem"})}),
42
+ _build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({**service_account, "private_key": bad_key})}),
43
43
  ] == [
44
44
  (ErrorCode.INVALID_CREDENTIALS, decode_error + "expected ident at line 1 column 2"),
45
45
  (ErrorCode.INVALID_CREDENTIALS, decode_error + "invalid type: integer `***`, expected a string at line 1 column 17"),
@@ -66,7 +66,7 @@ def test_an_s3_access_key_no_header_can_hold_is_invalid():
66
66
  "The S3 access key in the credentials contains whitespace or a control character",
67
67
  )
68
68
  assert [
69
- _build_error(s3, {"s3": {"accessKey": access_key, "secretKey": "s"}})
69
+ _build_error(s3, {"type": "s3", "accessKey": access_key, "secretKey": "s"})
70
70
  for access_key in ["AKIA\n", " AKIA", "AK\u0001IA", "AKIA"]
71
71
  ] == [error, error, error, None]
72
72
 
@@ -75,7 +75,7 @@ def test_a_rejected_credential_is_masked_however_rust_escapes_it():
75
75
  gcs = {"type": "gcs", "bucket": "b", "pathPrefix": None}
76
76
  # serde quotes a rejected string as Rust's Debug does, with \u{1} for the
77
77
  # control character, which neither of the redactor's variants matches.
78
- assert _build_error(gcs, {"gcs": {"serviceAccountJson": json.dumps("SECRET\u0001KEY")}}) == (
78
+ assert _build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps("SECRET\u0001KEY")}) == (
79
79
  ErrorCode.INVALID_CREDENTIALS,
80
80
  "The credentials couldn't be read: Generic GCS error: GCP credential error: Unable to decode service account"
81
81
  ' file: invalid type: string "***", expected struct ServiceAccountCredentials at line 1 column 17',
@@ -84,7 +84,7 @@ def test_a_rejected_credential_is_masked_however_rust_escapes_it():
84
84
 
85
85
  def test_an_address_no_url_can_hold_is_unreachable():
86
86
  azure = {"type": "azureBlob", "accountName": "my account", "container": "c", "pathPrefix": None}
87
- assert _build_error(azure, {"azureBlob": {"sasToken": "sv=1&sig=2"}}) == (
87
+ assert _build_error(azure, {"type": "azureBlob", "sasToken": "sv=1&sig=2"}) == (
88
88
  ErrorCode.UNREACHABLE,
89
89
  "The container 'c' of account 'my account' couldn't be reached: Generic MicrosoftAzure error: Unable parse"
90
90
  " source url. Url: https://my account.blob.core.windows.net, Error: invalid international domain name",
@@ -96,7 +96,7 @@ wheels = [
96
96
 
97
97
  [[package]]
98
98
  name = "dq-export-connector"
99
- version = "0.1.0.dev11"
99
+ version = "0.1.0.dev12"
100
100
  source = { editable = "." }
101
101
  dependencies = [
102
102
  { name = "pydantic" },