def test_get_csrs(): module = DummyModule({}) output_file = os.path.join(ASSET_PATH, 'oc_csr_approve_pending.json') with open(output_file) as stdoutfile: oc_get_csr_out = stdoutfile.read() # mock oc get csr call to cluster with patch(RUN_CMD_MOCK) as call_mock: call_mock.return_value = (0, oc_get_csr_out, '') csrs = oc_csr_approve.get_csrs(module, 'oc', '/dev/null') assert csrs[0]['kind'] == "CertificateSigningRequest" output_file = os.path.join(ASSET_PATH, 'openssl1.txt') with open(output_file) as stdoutfile: openssl_out = stdoutfile.read() # mock openssl req call. node_list = ['fedora2.mguginolocal.com'] with patch(RUN_CMD_MOCK) as call_mock: call_mock.return_value = (0, openssl_out, '') csr_dict = oc_csr_approve.process_csrs(module, csrs, node_list, "client") # actually run openssl req call. csr_dict = oc_csr_approve.process_csrs(module, csrs, node_list, "client") assert csr_dict[ 'node-csr-TkefytQp8Dz4Xp7uzcw605MocvI0gWuEOGNrHhOjGNQ'] == 'fedora2.mguginolocal.com'
def test_get_csrs(): module = DummyModule({}) output_file = os.path.join(ASSET_PATH, 'oc_csr_approve_pending.json') with open(output_file) as stdoutfile: oc_get_csr_out = stdoutfile.read() # mock oc get csr call to cluster with patch(RUN_CMD_MOCK) as call_mock: call_mock.return_value = (0, oc_get_csr_out, '') csrs = oc_csr_approve.get_csrs(module, 'oc', '/dev/null') assert csrs[0]['kind'] == "CertificateSigningRequest" output_file = os.path.join(ASSET_PATH, 'openssl1.txt') with open(output_file) as stdoutfile: openssl_out = stdoutfile.read() # mock openssl req call. node_list = ['fedora2.mguginolocal.com'] with patch(RUN_CMD_MOCK) as call_mock: call_mock.return_value = (0, openssl_out, '') csr_dict = oc_csr_approve.process_csrs(module, csrs, node_list, "client") # actually run openssl req call. csr_dict = oc_csr_approve.process_csrs(module, csrs, node_list, "client") assert csr_dict['node-csr-TkefytQp8Dz4Xp7uzcw605MocvI0gWuEOGNrHhOjGNQ'] == 'fedora2.mguginolocal.com'
def test_get_csrs_server(): module = DummyModule({}) output_file = os.path.join(ASSET_PATH, 'oc_csr_server_multiple_pends_one_host.json') with open(output_file) as stdoutfile: oc_get_csr_out = stdoutfile.read() # mock oc get csr call to cluster with patch(RUN_CMD_MOCK) as call_mock: call_mock.return_value = (0, oc_get_csr_out, '') csrs = oc_csr_approve.get_csrs(module, 'oc', '/dev/null') assert csrs[0]['kind'] == "CertificateSigningRequest" output_file = os.path.join(ASSET_PATH, 'openssl1.txt') with open(output_file) as stdoutfile: openssl_out = stdoutfile.read() node_list = ['fedora1.openshift.io'] # mock openssl req call. with patch(RUN_CMD_MOCK) as call_mock: call_mock.return_value = (0, openssl_out, '') csr_dict = oc_csr_approve.process_csrs(module, csrs, node_list, "server") # actually run openssl req call. node_list = ['fedora2.mguginolocal.com'] csr_dict = oc_csr_approve.process_csrs(module, csrs, node_list, "server") assert csr_dict['csr-2cxkp'] == 'fedora2.mguginolocal.com'