Skip to content

Commit

Permalink
client: test mutually exclusive provision args [MILK-135]
Browse files Browse the repository at this point in the history
[MILK-135]
  • Loading branch information
Prime541 committed Jun 18, 2024
1 parent 2d41bea commit a13cd49
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aiven/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5942,6 +5942,10 @@ def byoc__list(self) -> None:
)
def byoc__provision(self) -> None:
"""Provision resources for a Bring Your Own Cloud cloud."""
if self.args.aws_iam_role_arn and self.args.google_privilege_bearing_service_account_id:
raise argx.UserError(
"--aws-iam-role-arn and --google-privilege-bearing-service-account-id are mutually exclusive."
)
output = self.client.byoc_provision(
organization_id=self.args.organization_id,
byoc_id=self.args.byoc_id,
Expand Down
15 changes: 15 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,21 @@ def test_byoc_provision(provider: str, region: str, byoc_account_id: str) -> Non
)


def test_byoc_provision_args() -> None:
aiven_client = mock.Mock(spec_set=AivenClient)
args = [
"byoc",
"provision",
"--organization-id=org123456789a",
"--byoc-id=d6a490ad-f43d-49d8-b3e5-45bc5dbfb387",
"--aws-iam-role-arn=arn:aws:iam::123456789012:role/role-name",
"--google-privilege-bearing-service-account-id="
"projects/aiven-test-byoa/serviceAccounts/aiven-cce4bafaf95155@aiven-test-byoa.iam.gserviceaccount.com",
]
build_aiven_cli(aiven_client).run(args=args)
aiven_client.byoc_provision.assert_not_called()


def test_byoc_delete() -> None:
aiven_client = mock.Mock(spec_set=AivenClient)
aiven_client.byoc_delete.return_value = {"message": "deleting"}
Expand Down

0 comments on commit a13cd49

Please sign in to comment.