Skip to content

Commit

Permalink
authz: Enable wildcard principal tests (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejona86 authored Jul 29, 2024
1 parent 323f424 commit 3ad61fc
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions tests/authz_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,19 @@ def authz_rules(self):
},
},
},
# b/202058316. The wildcard principal is generating invalid config
# {
# "sources": {
# "principals": ["*"],
# },
# "destinations": {
# "hosts": [f"*:{self.server_xds_port}"],
# "ports": [self.server_port],
# "httpHeaderMatch": {
# "headerName": "test",
# "regexMatch": "principal-present",
# },
# },
# },
{
"sources": {
"principals": ["*"],
},
"destinations": {
"hosts": [f"*:{self.server_xds_port}"],
"ports": [self.server_port],
"httpHeaderMatch": {
"headerName": "test",
"regexMatch": "principal-present",
},
},
},
{
"sources": [
{
Expand Down Expand Up @@ -294,10 +293,12 @@ def test_plaintext_allow(self) -> None:
grpc.StatusCode.PERMISSION_DENIED,
)

# b/202058316
# with self.subTest('07_principal_present'):
# self.configure_and_assert(test_client, 'principal-present',
# grpc.StatusCode.PERMISSION_DENIED)
with self.subTest("07_principal_present"):
self.configure_and_assert(
test_client,
"principal-present",
grpc.StatusCode.PERMISSION_DENIED,
)

def test_tls_allow(self) -> None:
self.setupTrafficDirectorGrpc()
Expand All @@ -324,10 +325,12 @@ def test_tls_allow(self) -> None:
test_client, None, grpc.StatusCode.PERMISSION_DENIED
)

# b/202058316
# with self.subTest('03_principal_present'):
# self.configure_and_assert(test_client, 'principal-present',
# grpc.StatusCode.PERMISSION_DENIED)
with self.subTest("03_principal_present"):
self.configure_and_assert(
test_client,
"principal-present",
grpc.StatusCode.PERMISSION_DENIED,
)

def test_mtls_allow(self) -> None:
self.setupTrafficDirectorGrpc()
Expand All @@ -351,10 +354,10 @@ def test_mtls_allow(self) -> None:
test_client, None, grpc.StatusCode.PERMISSION_DENIED
)

# b/202058316
# with self.subTest('03_principal_present'):
# self.configure_and_assert(test_client, 'principal-present',
# grpc.StatusCode.OK)
with self.subTest("03_principal_present"):
self.configure_and_assert(
test_client, "principal-present", grpc.StatusCode.OK
)

with self.subTest("04_match_principal"):
self.configure_and_assert(
Expand Down

0 comments on commit 3ad61fc

Please sign in to comment.