Skip to content

Commit

Permalink
Removed unnecessary namespace references from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tymuraheiev committed Jan 21, 2025
1 parent 36e16d2 commit b9f2831
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
conformance/__pycache__/
src/__pycache__/
src/tests/__pycache__/
yaml/Object_example/debug-*
Expand Down
5 changes: 1 addition & 4 deletions conformance/cluster-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ apiVersion: clustersecret.io/v1
kind: ClusterSecret
metadata:
name: basic-cluster-secret
namespace: example-1
data:
username: MTIzNDU2Cg==
password: MTIzNDU2Cg==
---
kind: ClusterSecret
apiVersion: clustersecret.io/v1
kind: ClusterSecret
metadata:
name: typed-secret
namespace: example-1
type: kubernetes.io/tls
data:
tls.crt: MTIzNDU2Cg==
Expand All @@ -21,7 +19,6 @@ apiVersion: clustersecret.io/v1
kind: ClusterSecret
metadata:
name: basic-cluster-secret
namespace: example-1
avoidNamespaces:
- example-3
---
3 changes: 1 addition & 2 deletions conformance/k8s_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ def update_data_cluster_secret(

def delete_cluster_secret(
self,
name: str,
namespace: str
name: str
):
self.custom_objects_api.delete_cluster_custom_object(
name=name,
Expand Down
3 changes: 1 addition & 2 deletions conformance/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ def test_simple_cluster_secret_deleted(self):
)

self.cluster_secret_manager.delete_cluster_secret(
name=name,
namespace=USER_NAMESPACES[0],
name=name
)

# We expect the secret to be in NO namespaces
Expand Down
16 changes: 3 additions & 13 deletions src/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_on_field_data_cache(self):
csec = BaseClusterSecret(
uid="mysecretuid",
name="mysecret",
namespace="",
body={"metadata": {"name": "mysecret", "uid": "mysecretuid"}, "data": {"key": "oldvalue"}},
synced_namespace=[],
)
Expand All @@ -42,7 +41,6 @@ def test_on_field_data_cache(self):
body=new_body,
meta=kopf.Meta({"metadata": {"name": "mysecret"}}),
name="mysecret",
namespace=None,
uid="mysecretuid",
logger=self.logger,
)
Expand Down Expand Up @@ -75,7 +73,6 @@ def test_on_field_data_sync(self):
csec = BaseClusterSecret(
uid="mysecretuid",
name="mysecret",
namespace="",
body={
"metadata": {"name": "mysecret", "uid": "mysecretuid"},
"data": {"key": "oldvalue"},
Expand All @@ -100,7 +97,6 @@ def test_on_field_data_sync(self):
body=new_body,
meta=kopf.Meta({"metadata": {"name": "mysecret"}}),
name="mysecret",
namespace=None,
uid="mysecretuid",
logger=self.logger,
)
Expand Down Expand Up @@ -203,7 +199,6 @@ def read_namespace(name, **kwargs):
csec = BaseClusterSecret(
uid="mysecretuid",
name="mysecret",
namespace="",
body={
"metadata": {"name": "mysecret", "uid": "mysecretuid"},
"data": {"key": "oldvalue"},
Expand All @@ -229,7 +224,6 @@ def read_namespace(name, **kwargs):
body=new_body,
meta=kopf.Meta({"metadata": {"name": "mysecret"}}),
name="mysecret",
namespace=None,
uid="mysecretuid",
logger=self.logger,
)
Expand Down Expand Up @@ -265,7 +259,6 @@ def test_create_fn(self):
body = {
"metadata": {
"name": "mysecret",
"namespace": "myclustersecretnamespace",
"uid": "mysecretuid"
},
"data": {"key": "value"}
Expand All @@ -284,15 +277,14 @@ def test_create_fn(self):
logger=self.logger,
uid="mysecretuid",
name="mysecret",
namespace="myclustersecretnamespace",
body=body,
)
)

# ClusterSecret with a correct namespace should be in the cache.
# The secrets should be in all namespaces of the cache.
self.assertEqual(
csecs_cache.get_cluster_secret("mysecretuid").namespace,
"myclustersecretnamespace",
csecs_cache.get_cluster_secret("mysecretuid").synced_namespace,
["default", "myns"],
)

def test_ns_create(self):
Expand All @@ -312,7 +304,6 @@ def test_ns_create(self):
csec = BaseClusterSecret(
uid="mysecretuid",
name="mysecret",
namespace="",
body={"metadata": {"name": "mysecret"}, "data": "mydata"},
synced_namespace=["default"],
)
Expand Down Expand Up @@ -358,7 +349,6 @@ def test_startup_fn(self):
csec = BaseClusterSecret(
uid="mysecretuid",
name="mysecret",
namespace="",
body={"metadata": {"name": "mysecret", "uid": "mysecretuid"}, "data": "mydata"},
synced_namespace=[],
)
Expand Down

0 comments on commit b9f2831

Please sign in to comment.