forked from Kuadrant/testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for invalid credentials in dns provider
Signed-off-by: averevki <[email protected]>
- Loading branch information
Showing
4 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
51 changes: 51 additions & 0 deletions
51
testsuite/tests/singlecluster/gateway/dnspolicy/test_invalid_credentials.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Test DNSPolicy behavior when invalid credentials are provided""" | ||
|
||
import pytest | ||
|
||
from testsuite.kubernetes.secret import Secret | ||
from testsuite.kuadrant.policy import has_condition | ||
from testsuite.kuadrant.policy.dns import has_record_condition | ||
from testsuite.gateway.gateway_api.gateway import KuadrantGateway | ||
|
||
pytestmark = [pytest.mark.kuadrant_only, pytest.mark.dnspolicy] | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def gateway(request, cluster, blame, wildcard_domain, module_label): | ||
"""Create gateway without TLS enabled""" | ||
gw = KuadrantGateway.create_instance(cluster, blame("gw"), wildcard_domain, {"app": module_label}, tls=False) | ||
request.addfinalizer(gw.delete) | ||
gw.commit() | ||
gw.wait_for_ready() | ||
return gw | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def dns_provider_secret(request, cluster, module_label, blame): | ||
"""Create AWS provider secret with invalid credentials""" | ||
creds = { | ||
"AWS_ACCESS_KEY_ID": "ABCDEFGHIJKL", | ||
"AWS_SECRET_ACCESS_KEY": "abcdefg12345+", | ||
} | ||
|
||
secret = Secret.create_instance(cluster, blame("creds"), creds, "kuadrant.io/aws", labels={"app": module_label}) | ||
request.addfinalizer(secret.delete) | ||
secret.commit() | ||
return secret.name() | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def commit(request, route, dns_policy): # pylint: disable=unused-argument | ||
"""Commits dnspolicy without waiting for it to be ready""" | ||
request.addfinalizer(dns_policy.delete) | ||
dns_policy.commit() | ||
|
||
|
||
def test_invalid_credentials(dns_policy): | ||
"""Verify that DNSPolicy is not ready or enforced when invalid credentials are provided""" | ||
assert dns_policy.wait_until( | ||
has_condition("Enforced", "False") | ||
), f"DNSPolicy did not reach expected status, instead it was: {dns_policy.model.status.conditions}" | ||
assert dns_policy.wait_until( | ||
has_record_condition("Ready", "False", "DNSProviderError", "InvalidClientTokenId") | ||
), f"DNSPolicy did not reach expected record status, instead it was: {dns_policy.model.status.recordConditions}" |