8
8
from test_base import TestBase
9
9
10
10
from warnet .k8s import get_kubeconfig_value
11
+ from warnet .process import run_command
11
12
12
13
13
14
class NamespaceAdminTest (TestBase ):
@@ -26,10 +27,17 @@ def run_test(self):
26
27
self .setup_namespaces ()
27
28
self .setup_service_accounts ()
28
29
self .deploy_network_in_team_namespaces ()
29
- self .authenticate_bob ()
30
+ self .authenticate_and_become_bob ()
31
+ self .become_minikube_once_again ()
30
32
finally :
31
33
self .cleanup ()
32
34
35
+ def become_minikube_once_again (self ):
36
+ minikube = "minikube"
37
+ cmd = f"kubectl config use-context { minikube } "
38
+ self .log .info (run_command (cmd ))
39
+ self .wait_for_predicate (self .this_is_the_current_context (minikube ))
40
+
33
41
def this_is_the_current_context (self , context : str ) -> Callable [[], bool ]:
34
42
cmd = "kubectl config current-context"
35
43
current_context = run_command (cmd ).strip ()
@@ -80,10 +88,11 @@ def deploy_network_in_team_namespaces(self):
80
88
self .log .info (f"Deploying network into: { namespace } " )
81
89
self .log .info (self .warnet (f"deploy networks/{ network_name } / --namespace { namespace } " ))
82
90
self .wait_for_all_tanks_status ()
91
+ self .log .info ("Waiting for all edges" )
83
92
self .wait_for_all_edges ()
84
93
85
- def authenticate_bob (self ):
86
- self .log .info ("Authenticating bob..." )
94
+ def authenticate_and_become_bob (self ):
95
+ self .log .info ("Authenticating and becoming bob..." )
87
96
assert get_kubeconfig_value ("{.current-context}" ) == "minikube"
88
97
self .log .info (self .warnet ("auth kubeconfigs/bob-wargames-red-team-kubeconfig" ))
89
98
assert get_kubeconfig_value ("{.current-context}" ) == "bob-wargames-red-team"
0 commit comments