def test_get_one_secret(self): name = self.name filename = "/tmp/{}.json".format(name) with salt.utils.files.fopen(filename, "w") as f: salt.utils.json.dump(self.request, f) create = Popen( ["kubectl", "--namespace=default", "create", "-f", filename], stdout=PIPE) # wee need to give kubernetes time save data in etcd time.sleep(0.1) res = k8s.get_secrets("default", name, apiserver_url="http://127.0.0.1:8080") a = res.get("metadata", {}).get("name", "a") proc = Popen( [ "kubectl", "--namespace=default", "get", "secrets", name, "-o", "json" ], stdout=PIPE, ) kubectl_out = salt.utils.json.loads(proc.communicate()[0]) b = kubectl_out.get("metadata", {}).get("name", "b") self.assertEqual(a, b)
def test_get_secrets(self): res = k8s.get_secrets("default", apiserver_url="http://127.0.0.1:8080") a = len(res.get("items", [])) proc = Popen(["kubectl", "--namespace=default", "get", "secrets", "-o", "json"], stdout=PIPE) kubectl_out = salt.utils.json.loads(proc.communicate()[0]) b = len(kubectl_out.get("items", [])) self.assertEqual(a, b)
def test_get_secrets(self): res = k8s.get_secrets("default", apiserver_url="http://127.0.0.1:8080") a = len(res.get("items", [])) proc = Popen(["kubectl", "--namespace=default", "get", "secrets", "-o", "json"], stdout=PIPE) kubectl_out = json.loads(proc.communicate()[0]) b = len(kubectl_out.get("items", [])) self.assertEqual(a, b)
def test_get_decoded_secret(self): name = self.name filename = "/tmp/{0}.json".format(name) with salt.utils.files.fopen(filename, 'w') as f: salt.utils.json.dump(self.request, f) create = Popen(["kubectl", "--namespace=default", "create", "-f", filename], stdout=PIPE) # wee need to give etcd to populate data on all nodes time.sleep(0.1) res = k8s.get_secrets("default", name, apiserver_url="http://127.0.0.1:8080", decode=True) a = res.get("data", {}).get("testsecret", ) self.assertEqual(a, "teststring")
def test_get_decoded_secret(self): name = self.name filename = "/tmp/{0}.json".format(name) with open(filename, 'w') as f: json.dump(self.request, f) create = Popen(["kubectl", "--namespace=default", "create", "-f", filename], stdout=PIPE) # wee need to give etcd to populate data on all nodes time.sleep(0.1) res = k8s.get_secrets("default", name, apiserver_url="http://127.0.0.1:8080", decode=True) a = res.get("data", {}).get("testsecret", ) self.assertEqual(a, "teststring")
def test_get_one_secret(self): name = self.name filename = "/tmp/{0}.json".format(name) with open(filename, 'w') as f: json.dump(self.request, f) create = Popen(["kubectl", "--namespace=default", "create", "-f", filename], stdout=PIPE) # wee need to give kubernetes time save data in etcd time.sleep(0.1) res = k8s.get_secrets("default", name, apiserver_url="http://127.0.0.1:8080") a = res.get("metadata", {}).get("name", "a") proc = Popen(["kubectl", "--namespace=default", "get", "secrets", name, "-o", "json"], stdout=PIPE) kubectl_out = json.loads(proc.communicate()[0]) b = kubectl_out.get("metadata", {}).get("name", "b") self.assertEqual(a, b)