|
60 | 60 | "X-Client-Version": "0.14.1",
|
61 | 61 | "User-Agent": f"PyIceberg/{pyiceberg.__version__}",
|
62 | 62 | "Authorization": f"Bearer {TEST_TOKEN}",
|
| 63 | + "X-Iceberg-Access-Delegation": "vended-credentials", |
63 | 64 | }
|
64 | 65 | OAUTH_TEST_HEADERS = {
|
65 | 66 | "Content-type": "application/x-www-form-urlencoded",
|
@@ -708,6 +709,38 @@ def test_load_table_200(rest_mock: Mocker, example_table_metadata_with_snapshot_
|
708 | 709 | assert actual == expected
|
709 | 710 |
|
710 | 711 |
|
| 712 | +def test_load_table_honor_access_delegation( |
| 713 | + rest_mock: Mocker, example_table_metadata_with_snapshot_v1_rest_json: Dict[str, Any] |
| 714 | +) -> None: |
| 715 | + test_headers_with_remote_signing = {**TEST_HEADERS, "X-Iceberg-Access-Delegation": "remote-signing"} |
| 716 | + rest_mock.get( |
| 717 | + f"{TEST_URI}v1/namespaces/fokko/tables/table", |
| 718 | + json=example_table_metadata_with_snapshot_v1_rest_json, |
| 719 | + status_code=200, |
| 720 | + request_headers=test_headers_with_remote_signing, |
| 721 | + ) |
| 722 | + # catalog = RestCatalog("rest", **{"uri": TEST_URI, "token": TEST_TOKEN, "access-delegation": "remote-signing"}) |
| 723 | + catalog = RestCatalog( |
| 724 | + "rest", |
| 725 | + **{ |
| 726 | + "uri": TEST_URI, |
| 727 | + "token": TEST_TOKEN, |
| 728 | + "header.X-Iceberg-Access-Delegation": "remote-signing", |
| 729 | + }, |
| 730 | + ) |
| 731 | + actual = catalog.load_table(("fokko", "table")) |
| 732 | + expected = Table( |
| 733 | + identifier=("fokko", "table"), |
| 734 | + metadata_location=example_table_metadata_with_snapshot_v1_rest_json["metadata-location"], |
| 735 | + metadata=TableMetadataV1(**example_table_metadata_with_snapshot_v1_rest_json["metadata"]), |
| 736 | + io=load_file_io(), |
| 737 | + catalog=catalog, |
| 738 | + ) |
| 739 | + # First compare the dicts |
| 740 | + assert actual.metadata.model_dump() == expected.metadata.model_dump() |
| 741 | + assert actual == expected |
| 742 | + |
| 743 | + |
711 | 744 | def test_load_table_from_self_identifier_200(
|
712 | 745 | rest_mock: Mocker, example_table_metadata_with_snapshot_v1_rest_json: Dict[str, Any]
|
713 | 746 | ) -> None:
|
|
0 commit comments