diff options
| author | Niranjan Mallapadi <mrniranjan@redhat.com> | 2015-10-01 18:38:34 +0530 |
|---|---|---|
| committer | Niranjan Mallapadi <mrniranjan@redhat.com> | 2015-10-01 18:51:37 +0530 |
| commit | fd8bc4fe1acceba7f88b71a44e43d2993056cfd3 (patch) | |
| tree | 733a5c77ed1cc67908333e85f7be8aba2456f411 | |
| parent | 3292de07ed01f6230de34120bf9cd1b8d164610a (diff) | |
Add pytest tests and documentation.
Currently only installation tests have been
written.
pytest/docs contain the documentation of
how to use multihost plugin and documentation
of shared functions used
Signed-off-by: Niranjan Mallapadi <mrniranjan@redhat.com>
| -rw-r--r-- | tests/dogtag/pytest/cli/installation/Test_Multihostdiscrete.py | 717 | ||||
| -rw-r--r-- | tests/dogtag/pytest/cli/installation/Test_sharedInstance.py | 140 | ||||
| -rw-r--r-- | tests/dogtag/pytest/cli/installation/conftest.py | 78 | ||||
| -rw-r--r-- | tests/dogtag/pytest/cli/installation/constants.py | 90 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/Install.rst | 39 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/Makefile | 189 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/api.rst | 18 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/conf.py | 301 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/conftest.rst | 159 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/examples.rst | 52 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/index.rst | 39 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/layout.rst | 19 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/multihost.rst | 121 | ||||
| -rw-r--r-- | tests/dogtag/pytest/docs/running.rst | 86 | ||||
| -rw-r--r-- | tests/dogtag/pytest/legacy/a | 0 | ||||
| -rw-r--r-- | tests/dogtag/pytest/ui/a | 0 |
16 files changed, 2048 insertions, 0 deletions
diff --git a/tests/dogtag/pytest/cli/installation/Test_Multihostdiscrete.py b/tests/dogtag/pytest/cli/installation/Test_Multihostdiscrete.py new file mode 100644 index 000000000..6d91630fe --- /dev/null +++ b/tests/dogtag/pytest/cli/installation/Test_Multihostdiscrete.py @@ -0,0 +1,717 @@ +from pkilib.common.exceptions import DirSrvException +from subprocess import CalledProcessError +import pytest +import constants +import ConfigParser +import time + +class Testclass: + """ Subsystem installation tests under discrete tomcat instaces """ + def class_setup(self, multihost, DSInstance): + """ + @Setup: + 1. Setup Directory Server Instances on Master + 2. Setup Directory Server Instances on Clone + """ + master_ds = DSInstance[0] + DSInstanceList = [constants.CA_INSTANCE_NAME, + constants.KRA_INSTANCE_NAME, + constants.OCSP_INSTANCE_NAME, + constants.TKS_INSTANCE_NAME, + constants.TPS_INSTANCE_NAME] + for Instance in DSInstanceList: + try: + ret = master_ds._CreateInstance(Instance) + except DirSrvException as e: + mulitihost.master.log.info('Could not setup DS Instance') + assert False + else: + multihost.master.log.info('Successfully setup %s DS Instance' %(Instance)) + clone_ds = DSInstance[1] + DSInstanceList = [constants.CLONECA_INSTANCE_NAME, + constants.CLONEKRA_INSTANCE_NAME, + constants.CLONEOCSP_INSTANCE_NAME, + constants.CLONETKS_INSTANCE_NAME, + constants.CLONETPS_INSTANCE_NAME] + for Instance in DSInstanceList: + try: + ret = clone_ds._CreateInstance(Instance) + except DirSrvException as e: + mulitihost.clone.log.info('Could not setup DS Instance') + assert False + else: + multihost.clone.log.info('Successfully setup %s DS Instance' %(Instance)) + + def testConfigCA(self, multihost, TempFile, DSInstance): + """@Test: Install CA subsystem + @Steps: + 1. Setup Directory Server Instance + 2. Setup CA instance with tomcat instance name 'Foobar1' + + @Assert: Verify pkispawn executed successfuly + """ + + #setup CA instance configuration file + master_ds = DSInstance[0] + ldap_port = master_ds.DSUsedPorts[constants.CA_INSTANCE_NAME][0] + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.CA_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.CA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.CA_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.CA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.CA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_name", constants.CA_SECURITY_DOMAIN_NAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.CA_CLIENT_DIR) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("DEFAULT", "pki_backup_keys", "True") + pkiconfig.set("DEFAULT", "pki_backup_password", constants.BACKUP_PASSWORD) + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.CA_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.CA_TOMCAT_PORT) + pkiconfig.add_section("CA") + pkiconfig.set("CA", "pki_import_admin_cert", "False") + pkiconfig.set("CA", "pki_ds_hostname", master_ds.DSInstHost) + pkiconfig.set("CA", "pki_ds_ldap_port", ldap_port) + pkiconfig.set("CA", "pki_ds_password", master_ds.DSRootDNPwd) + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + #copy configuration file to master + multihost.master.transport.put_file(TempFile, '/tmp/ca_cfg') + + #Run pkispawn + output = multihost.master.run_command(['pkispawn', '-s', 'CA', '-f', '/tmp/ca_cfg', '-vv']) + assert 0 == output.returncode + output = multihost.master.run_command(['scp', '/var/lib/pki/%s/alias/ca_backup_keys.p12' %(constants.CA_INSTANCE_NAME), '%s:/tmp' % (multihost.clone.hostname)]) + assert 0 == output.returncode + time.sleep(10) + + def testConfigKRA(self, multihost, TempFile,DSInstance): + """@Test: Install KRA Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by KRA subsystems + 2. Create configurtion file specifying details of KRA, DS instance and Ports to be used + 3. Run pkispawn with `pkispawn -s KRA -f <configuration-file> -vv + + @Assert: Verify pkispawn command ran successfuly + """ + + #setup KRA instance configuration file + master_ds = DSInstance[0] + ldap_port = master_ds.DSUsedPorts[constants.KRA_INSTANCE_NAME][0] + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.KRA_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.KRA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.KRA_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.KRA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.KRA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_https_port", constants.CA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.KRA_CLIENT_DIR) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("DEFAULT", "pki_backup_keys", "True") + pkiconfig.set("DEFAULT", "pki_backup_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.BACKUP_PASSWORD) + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.KRA_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.KRA_TOMCAT_PORT) + pkiconfig.add_section("KRA") + pkiconfig.set("KRA", "pki_import_admin_cert", "False") + pkiconfig.set("KRA", "pki_ds_hostname", master_ds.DSInstHost) + pkiconfig.set("KRA", "pki_ds_ldap_port", ldap_port) + pkiconfig.set("KRA", "pki_ds_password", master_ds.DSRootDNPwd) + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + #copy configuration file to master + multihost.master.transport.put_file(TempFile, '/tmp/kra_cfg') + + #Run pkispawn + output = multihost.master.run_command(['pkispawn', '-s', 'KRA', '-f', '/tmp/kra_cfg', '-vv']) + assert 0 == output.returncode + output = multihost.master.run_command(['scp', '/var/lib/pki/%s/alias/kra_backup_keys.p12' %(constants.KRA_INSTANCE_NAME), '%s:/tmp' % (multihost.clone.hostname)]) + assert 0 == output.returncode + + def testConfigOCSP(self, multihost, TempFile,DSInstance): + """@Test: Install OCSP Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by OCSP subsystems + 2. Create configurtion file specifying details of OCSP, DS instance and Ports to be used + 3. Run pkispawn with `pkispawn -s KRA -f <configuration-file> -vv + + @Assert: Verify pkispawn command ran successfuly + """ + #setup OCSP instance configuration file + master_ds = DSInstance[0] + ldap_port = master_ds.DSUsedPorts[constants.OCSP_INSTANCE_NAME][0] + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.OCSP_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.OCSP_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.OCSP_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.OCSP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.OCSP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_https_port", constants.CA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.OCSP_CLIENT_DIR) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("DEFAULT", "pki_backup_keys", "True") + pkiconfig.set("DEFAULT", "pki_backup_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.BACKUP_PASSWORD) + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.OCSP_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.OCSP_TOMCAT_PORT) + pkiconfig.add_section("OCSP") + pkiconfig.set("OCSP", "pki_import_admin_cert", "False") + pkiconfig.set("OCSP", "pki_ds_hostname", master_ds.DSInstHost) + pkiconfig.set("OCSP", "pki_ds_ldap_port", ldap_port) + pkiconfig.set("OCSP", "pki_ds_password", master_ds.DSRootDNPwd) + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + #copy configuration file to master + multihost.master.transport.put_file(TempFile, '/tmp/ocsp_cfg') + + #Run pkispawn + output = multihost.master.run_command(['pkispawn', '-s', 'OCSP', '-f', '/tmp/ocsp_cfg', '-vv']) + assert 0 == output.returncode + output = multihost.master.run_command(['scp', '/var/lib/pki/%s/alias/ocsp_backup_keys.p12' %(constants.OCSP_INSTANCE_NAME), '%s:/tmp' % (multihost.clone.hostname)]) + assert 0 == output.returncode + + def testConfigTKS(self, multihost, TempFile,DSInstance): + """@Test: Install TKS Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by TKS subsystems + 2. Create configurtion file specifying details of TKS, DS instance and Ports to be used + 3. Run pkispawn with `pkispawn -s TKS -f <configuration-file> -vv + + @Assert: Verify pkispawn command ran successfuly + """ + #setup TKS instance configuration file + master_ds = DSInstance[0] + ldap_port = master_ds.DSUsedPorts[constants.TKS_INSTANCE_NAME][0] + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.TKS_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.TKS_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.TKS_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.TKS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.TKS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_https_port", constants.CA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.TKS_CLIENT_DIR) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("DEFAULT", "pki_backup_keys", "True") + pkiconfig.set("DEFAULT", "pki_backup_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.BACKUP_PASSWORD) + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.TKS_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.TKS_TOMCAT_PORT) + pkiconfig.add_section("TKS") + pkiconfig.set("TKS", "pki_import_admin_cert", "False") + pkiconfig.set("TKS", "pki_ds_hostname", master_ds.DSInstHost) + pkiconfig.set("TKS", "pki_ds_ldap_port", ldap_port) + pkiconfig.set("TKS", "pki_ds_password", master_ds.DSRootDNPwd) + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + #copy configuration file to master + multihost.master.transport.put_file(TempFile, '/tmp/tks_cfg') + + #Run pkispawn + output = multihost.master.run_command(['pkispawn', '-s', 'TKS', '-f', '/tmp/tks_cfg', '-vv']) + assert 0 == output.returncode + output = multihost.master.run_command(['scp', '/var/lib/pki/%s/alias/tks_backup_keys.p12' %(constants.TKS_INSTANCE_NAME), '%s:/tmp' % (multihost.clone.hostname)]) + assert 0 == output.returncode + + + def testConfigTPS(self, multihost, TempFile,DSInstance): + """@Test: Install TPS Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by TPS subsystems + 2. Create configurtion file specifying details of TPS, DS instance and Ports to be used + 3. Run pkispawn with `pkispawn -s TPS -f <configuration-file> -vv + + @Assert: Verify pkispawn command ran successfuly + """ + #setup TPS instance configuration file + master_ds = DSInstance[0] + ldap_port = master_ds.DSUsedPorts[constants.TPS_INSTANCE_NAME][0] + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.TPS_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.TPS_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.TPS_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.TPS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.TPS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_https_port", constants.CA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.TPS_CLIENT_DIR) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("DEFAULT", "pki_backup_keys", "True") + pkiconfig.set("DEFAULT", "pki_backup_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.BACKUP_PASSWORD) + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.TPS_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.TPS_TOMCAT_PORT) + pkiconfig.add_section("TPS") + pkiconfig.set("TPS", "pki_import_admin_cert", "False") + pkiconfig.set("TPS", "pki_ca_uri", "https://%s:%s" % (multihost.master.hostname, constants.CA_HTTPS_PORT)) + pkiconfig.set("TPS", "pki_kra_uri", "https://%s:%s"% (multihost.master.hostname, constants.KRA_HTTPS_PORT)) + pkiconfig.set("TPS", "pki_tks_uri", "https://%s:%s" % (multihost.master.hostname, constants.TKS_HTTPS_PORT )) + pkiconfig.set("TPS", "pki_authdb_hostname", master_ds.DSInstHost) + pkiconfig.set("TPS", "pki_authdb_port", ldap_port) + pkiconfig.set("TPS", "pki_authdb_basedn", "dc=example,dc=org") + pkiconfig.set("TPS", "pki_authdb_secure_conn", "False") + pkiconfig.set("TPS", "pki_import_shared_secret", "False") + pkiconfig.set("TPS", "pki_enable_server_side_keygen", "False") + pkiconfig.set("TPS", "pki_ds_hostname", master_ds.DSInstHost) + pkiconfig.set("TPS", "pki_ds_ldap_port", ldap_port) + pkiconfig.set("TPS", "pki_ds_password", master_ds.DSRootDNPwd) + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + #copy configuration file to master + multihost.master.transport.put_file(TempFile, '/tmp/tps_cfg') + + #Run pkispawn + output = multihost.master.run_command(['pkispawn', '-s', 'TPS', '-f', '/tmp/tps_cfg', '-vv']) + assert 0 == output.returncode + output = multihost.master.run_command(['scp', '/var/lib/pki/%s/alias/tps_backup_keys.p12' %(constants.TPS_INSTANCE_NAME), '%s:/tmp' % (multihost.clone.hostname)]) + assert 0 == output.returncode + + def testConfigCloneCA(self, multihost, TempFile, DSInstance): + """@Test: Configure Clone CA Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by Clone CA Subsystem + 2. Create configurtion file /tmp/ca_cfg specifying details of RootCA,Clone CA port and + DS instance + 3. Run pkispawn with `pkispawn -s CA -f /tmp/ca_cfg -vv + + @Assert: Verify pkispawn command ran successfuly + """ + + master_ds = DSInstance[0] + clone_ds = DSInstance[1] + master_ldap_port = master_ds.DSUsedPorts[constants.CA_INSTANCE_NAME][0] + clone_ldap_port = clone_ds.DSUsedPorts[constants.CLONECA_INSTANCE_NAME][0] + + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.CLONECA_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.CLONECA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.CLONECA_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.CLONECA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.CLONECA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_hostname", multihost.clone.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.CLONECA_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.CLONECA_TOMCAT_PORT) + pkiconfig.add_section("CA") + pkiconfig.set("CA", "pki_clone", "True") + pkiconfig.set("CA", "pki_clone_pkcs12_path", "/tmp/ca_backup_keys.p12") + pkiconfig.set("CA", "pki_clone_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("CA", "pki_clone_replicate_schema", "True") + pkiconfig.set("CA", "pki_clone_uri", "https://%s:%s" %(multihost.master.hostname, constants.CA_HTTPS_PORT)) + pkiconfig.set("CA", "pki_clone_replication_master_port", master_ldap_port) + pkiconfig.set("CA", "pki_clone_replication_clone_port", clone_ldap_port) + pkiconfig.set("CA", "pki_ds_ldap_port", clone_ldap_port) + pkiconfig.set("CA", "pki_ds_password", clone_ds.DSRootDNPwd) + pkiconfig.set("CA", "pki_ds_remove_data", "True") + pkiconfig.set("CA", "pki_ds_base_dn", "o=%s-CA"%(constants.CA_INSTANCE_NAME)) + + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + multihost.clone.transport.put_file(TempFile, '/tmp/ca_cfg') + output = multihost.clone.run_command(['pkispawn', '-s', 'CA', '-f', '/tmp/ca_cfg', '-vv']) + assert 0 == output.returncode + + def testConfigCloneKRA(self, multihost, TempFile, DSInstance): + """@Test: Configure Clone KRA Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by Clone KRA Subsystem + 2. Create configurtion file /tmp/kra_cfg specifying details of RootKRA, + Clone KRA port and DS instance + 3. Run pkispawn with `pkispawn -s KRA -f /tmp/kra_cfg -vv + + @Assert: Verify pkispawn command ran successfuly + """ + + master_ds = DSInstance[0] + clone_ds = DSInstance[1] + master_ldap_port = master_ds.DSUsedPorts[constants.KRA_INSTANCE_NAME][0] + clone_ldap_port = clone_ds.DSUsedPorts[constants.CLONEKRA_INSTANCE_NAME][0] + + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.CLONEKRA_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.CLONEKRA_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.CLONEKRA_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.CLONEKRA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.CLONEKRA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_hostname", multihost.clone.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.CLONEKRA_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.CLONEKRA_CLIENT_DIR) + + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.CLONEKRA_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.CLONEKRA_TOMCAT_PORT) + pkiconfig.add_section("KRA") + pkiconfig.set("KRA", "pki_clone", "True") + pkiconfig.set("KRA", "pki_clone_pkcs12_path", "/tmp/kra_backup_keys.p12") + pkiconfig.set("KRA", "pki_clone_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("KRA", "pki_clone_replicate_schema", "True") + pkiconfig.set("KRA", "pki_clone_uri", "https://%s:%s" %(multihost.master.hostname, constants.KRA_HTTPS_PORT)) + pkiconfig.set("KRA", "pki_clone_replication_master_port", master_ldap_port) + pkiconfig.set("KRA", "pki_clone_replication_clone_port", clone_ldap_port) + pkiconfig.set("KRA", "pki_ds_ldap_port", clone_ldap_port) + pkiconfig.set("KRA", "pki_ds_password", clone_ds.DSRootDNPwd) + pkiconfig.set("KRA", "pki_ds_remove_data", "True") + pkiconfig.set("KRA", "pki_ds_base_dn", "o=%s-KRA"%(constants.KRA_INSTANCE_NAME)) + + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + multihost.clone.transport.put_file(TempFile, '/tmp/kra_cfg') + output = multihost.clone.run_command(['pkispawn', '-s', 'KRA', '-f', '/tmp/kra_cfg', '-vv']) + + def testConfigCloneOCSP(self, multihost, TempFile, DSInstance): + """@Test: Configure Clone OCSP Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by Clone OCSP Subsystem + 2. Create configurtion file /tmp/ocsp_cfg specifying details of RootOCSP, + Clone OCSP port and DS instance + 3. Run pkispawn with `pkispawn -s OCSP -f /tmp/ocsp_cfg -vv + + @Assert: Verify pkispawn command ran successfuly + """ + + master_ds = DSInstance[0] + clone_ds = DSInstance[1] + master_ldap_port = master_ds.DSUsedPorts[constants.OCSP_INSTANCE_NAME][0] + clone_ldap_port = clone_ds.DSUsedPorts[constants.CLONEOCSP_INSTANCE_NAME][0] + + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.CLONEOCSP_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.CLONEOCSP_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.CLONEOCSP_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.CLONEOCSP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.CLONEOCSP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_hostname", multihost.clone.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.CLONEOCSP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.CLONEOCSP_CLIENT_DIR) + + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.CLONEOCSP_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.CLONEOCSP_TOMCAT_PORT) + pkiconfig.add_section("OCSP") + pkiconfig.set("OCSP", "pki_clone", "True") + pkiconfig.set("OCSP", "pki_clone_pkcs12_path", "/tmp/ocsp_backup_keys.p12") + pkiconfig.set("OCSP", "pki_clone_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("OCSP", "pki_clone_replicate_schema", "True") + pkiconfig.set("OCSP", "pki_clone_uri", "https://%s:%s" %(multihost.master.hostname, constants.OCSP_HTTPS_PORT)) + pkiconfig.set("OCSP", "pki_clone_replication_master_port", master_ldap_port) + pkiconfig.set("OCSP", "pki_clone_replication_clone_port", clone_ldap_port) + pkiconfig.set("OCSP", "pki_ds_ldap_port", clone_ldap_port) + pkiconfig.set("OCSP", "pki_ds_password", clone_ds.DSRootDNPwd) + pkiconfig.set("OCSP", "pki_ds_remove_data", "True") + pkiconfig.set("OCSP", "pki_ds_base_dn", "o=%s-OCSP"%(constants.OCSP_INSTANCE_NAME)) + + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + multihost.clone.transport.put_file(TempFile, '/tmp/ocsp_cfg') + output = multihost.clone.run_command(['pkispawn', '-s', 'OCSP', '-f', '/tmp/ocsp_cfg', '-vv']) + assert 0 == output.returncode + + def testConfigCloneTKS(self, multihost, TempFile, DSInstance): + """@Test: Configure Clone TKS Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by Clone TKS Subsystem + 2. Create configurtion file /tmp/tks_cfg specifying details of RootKRA, + Clone TKS port and DS instance + 3. Run pkispawn with `pkispawn -s TKS -f /tmp/tks_cfg -vv + + @Assert: Verify pkispawn command ran successfuly + """ + + master_ds = DSInstance[0] + clone_ds = DSInstance[1] + master_ldap_port = master_ds.DSUsedPorts[constants.TKS_INSTANCE_NAME][0] + clone_ldap_port = clone_ds.DSUsedPorts[constants.CLONETKS_INSTANCE_NAME][0] + + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.CLONETKS_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.CLONETKS_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.CLONETKS_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.CLONETKS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.CLONETKS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_hostname", multihost.clone.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.CLONETKS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.CLONETKS_CLIENT_DIR) + + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.CLONETKS_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.CLONETKS_TOMCAT_PORT) + pkiconfig.add_section("TKS") + pkiconfig.set("TKS", "pki_clone", "True") + pkiconfig.set("TKS", "pki_clone_pkcs12_path", "/tmp/tks_backup_keys.p12") + pkiconfig.set("TKS", "pki_clone_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("TKS", "pki_clone_replicate_schema", "True") + pkiconfig.set("TKS", "pki_clone_uri", "https://%s:%s" %(multihost.master.hostname, constants.TKS_HTTPS_PORT)) + pkiconfig.set("TKS", "pki_clone_replication_master_port", master_ldap_port) + pkiconfig.set("TKS", "pki_clone_replication_clone_port", clone_ldap_port) + pkiconfig.set("TKS", "pki_ds_ldap_port", clone_ldap_port) + pkiconfig.set("TKS", "pki_ds_password", clone_ds.DSRootDNPwd) + pkiconfig.set("TKS", "pki_ds_remove_data", "True") + pkiconfig.set("TKS", "pki_ds_base_dn", "o=%s-TKS"%(constants.TKS_INSTANCE_NAME)) + + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + multihost.clone.transport.put_file(TempFile, '/tmp/tks_cfg') + output = multihost.clone.run_command(['pkispawn', '-s', 'TKS', '-f', '/tmp/tks_cfg', '-vv']) + assert 0 == output.returncode + + @pytest.mark.xfail(reason='BZ-1190184',raises=CalledProcessError) + def testConfigCloneTPS(self, multihost, TempFile, DSInstance): + """@Test: Configure Clone TPS Subsystem on separate Tomcat Instance + + @steps: + 1. Setup Directory Server Instance to be used by Clone TPS Subsystem + 2. Create configurtion file /tmp/tps_cfg specifying details of RootTPS, + Clone TPS port and DS instance + 3. Run pkispawn with `pkispawn -s TPS -f /tmp/tps_cfg -vv + + @Assert: Verify pkispawn command ran successfuly + """ + + master_ds = DSInstance[0] + clone_ds = DSInstance[1] + master_ldap_port = master_ds.DSUsedPorts[constants.TPS_INSTANCE_NAME][0] + clone_ldap_port = clone_ds.DSUsedPorts[constants.CLONETPS_INSTANCE_NAME][0] + + pkiconfig = ConfigParser.RawConfigParser() + pkiconfig.optionxform = str + pkiconfig.set("DEFAULT", "pki_instance_name", constants.CLONETPS_INSTANCE_NAME) + pkiconfig.set("DEFAULT", "pki_https_port", constants.CLONETPS_HTTPS_PORT) + pkiconfig.set("DEFAULT", "pki_http_port", constants.CLONETPS_HTTP_PORT) + pkiconfig.set("DEFAULT", "pki_token_password", constants.CLONETPS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_admin_password", constants.CLONETPS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_hostname", multihost.clone.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_hostname", multihost.master.hostname) + pkiconfig.set("DEFAULT", "pki_security_domain_user", constants.CA_ADMIN_USERNAME) + pkiconfig.set("DEFAULT", "pki_security_domain_password", constants.SECURITY_DOMAIN_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_pkcs12_password", constants.BACKUP_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_database_password", constants.CLONETPS_PASSWORD) + pkiconfig.set("DEFAULT", "pki_client_dir", constants.CLONETPS_CLIENT_DIR) + + pkiconfig.add_section('Tomcat') + pkiconfig.set("Tomcat", "pki_ajp_port", constants.CLONETPS_AJP_PORT) + pkiconfig.set("Tomcat", "pki_tomcat_server_port", constants.CLONETPS_TOMCAT_PORT) + pkiconfig.add_section("TPS") + pkiconfig.set("TPS", "pki_clone", "True") + pkiconfig.set("TPS", "pki_clone_pkcs12_path", "/tmp/tps_backup_keys.p12") + pkiconfig.set("TPS", "pki_clone_pkcs12_password", constants.CLIENT_PKCS12_PASSWORD) + pkiconfig.set("TPS", "pki_clone_replicate_schema", "True") + pkiconfig.set("TPS", "pki_clone_uri", "https://%s:%s" %(multihost.master.hostname, constants.TPS_HTTPS_PORT)) + pkiconfig.set("TPS", "pki_clone_replication_master_port", master_ldap_port) + pkiconfig.set("TPS", "pki_clone_replication_clone_port", clone_ldap_port) + pkiconfig.set("TPS", "pki_ds_ldap_port", clone_ldap_port) + pkiconfig.set("TPS", "pki_ds_password", clone_ds.DSRootDNPwd) + pkiconfig.set("TPS", "pki_ds_remove_data", "True") + pkiconfig.set("TPS", "pki_ds_base_dn", "o=%s-TPS"%(constants.TPS_INSTANCE_NAME)) + pkiconfig.set("TPS", "pki_authdb_hostname", multihost.clone.hostname) + pkiconfig.set("TPS", "pki_authdb_port", clone_ldap_port) + pkiconfig.set("TPS", "pki_authdb_basedn", clone_ds.DSInstSuffix) + + with open(TempFile, "wb") as f: + pkiconfig.write(f) + + multihost.clone.transport.put_file(TempFile, '/tmp/tps_cfg') + output = multihost.clone.run_command(['pkispawn', '-s', 'TPS', '-f', '/tmp/tps_cfg', '-vv']) + assert 0 == output.returncode + + def testRemoveCloneCA(self, multihost): + """@Test: Remove Clone CA Subsystem + + @steps: + 1. Setup Clone CA Instance Foobar-CloneCA + 2. Run pkidestroy -s CA -i Foobar-CloneCA + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.clone.run_command(['pkidestroy', '-s', 'CA', '-i', constants.CLONECA_INSTANCE_NAME]) + + def testRemoveCloneKRA(self, multihost): + """@Test: Remove Clone KRA Subsystem + + @steps: + 1. Setup Clone KRA Instance Foobar-CloneKRA + 2. Run pkidestroy -s KRA -i Foobar-CloneKRA + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.clone.run_command(['pkidestroy', '-s', 'KRA', '-i', constants.CLONEKRA_INSTANCE_NAME]) + + def testRemoveCloneOCSP(self, multihost): + """@Test: Remove Clone OCSP Subsystem + + @steps: + 1. Setup Clone OCSP Instance Foobar-CloneOCSP + 2. Run pkidestroy -s OCSP -i Foobar-CloneOCSP + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.clone.run_command(['pkidestroy', '-s', 'OCSP', '-i', constants.CLONEOCSP_INSTANCE_NAME]) + + def testRemoveCloneTKS(self, multihost): + """@Test: Remove Clone TKS Subsystem + + @steps: + 1. Setup Clone TKS Instance Foobar-CloneTKS + 2. Run pkidestroy -s TKS -i Foobar-CloneTKS + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.clone.run_command(['pkidestroy', '-s', 'TKS', '-i', constants.CLONETKS_INSTANCE_NAME]) + + def testRemoveCloneTPS(self, multihost): + """@Test: Remove Clone TPS Subsystem + + @steps: + 1. Setup Clone TPS Instance Foobar-CloneTPS + 2. Run pkidestroy -s TPS -i Foobar-CloneTPS + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.clone.run_command(['pkidestroy', '-s', 'TPS', '-i', constants.CLONETPS_INSTANCE_NAME]) + + def testRemoveTPS(self, multihost): + """@Test: Remove TPS Subsystem + + @steps: + 1. Setup CA subsystem + 2. Setup KRA subsystem + 3. Setup TKS subsystem + 4. Setup TPS subsystem + 5. Run pkidestroy -s TPS -i <Instance Name> + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.master.run_command(['pkidestroy', '-s', 'TPS', '-i', constants.TPS_INSTANCE_NAME]) + + def testRemoveTKS(self, multihost): + """@Test: Remove TKS Subsystem + + @steps: + 1. Setup CA subsystem + 2. Setup KRA subsystem + 3. Setup TKS subsystem + 4. Run pkidestroy -s TKS -i <Instance Name> + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.master.run_command(['pkidestroy', '-s', 'TKS', '-i', constants.TKS_INSTANCE_NAME]) + + def testRemoveOCSP(self, multihost): + """@Test: Remove OCSP Subsystem + + @steps: + 1. Setup CA subsystem + 2. Setup OCSP subsystem + 3. Run pkidestroy -s OCSP -i <Instance Name> + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.master.run_command(['pkidestroy', '-s', 'OCSP', '-i', constants.OCSP_INSTANCE_NAME]) + + def testRemoveKRA(self, multihost): + """@Test: Remove KRA Subsystem + + @steps: + 1. Setup CA subsystem + 2. Setup KRA subsystem + 3. Run pkidestroy -s KRA -i <Instance Name> + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.master.run_command(['pkidestroy', '-s', 'KRA', '-i', constants.KRA_INSTANCE_NAME]) + + def testRemoveCA(self, multihost): + """@Test: Remove CA Subsystem + + @steps: + 1. Setup CA subsystem + 2. Run pkidestroy -s CA -i <Instance Name> + + @Assert: Verify pkidestroy command ran successfuly + """ + multihost.master.run_command(['pkidestroy', '-s', 'CA', '-i', constants.CA_INSTANCE_NAME]) + + def class_teardown(self, multihost, DSInstance): + """ + @Teardown: + 1. Remove Directory Server instances from Master + 2. Remove Directory Server instances from clone + """ + multihost.master.log.info('Remove Directory Server instances from Master') + print(".... teardown .... ") + master_ds = DSInstance[0] + DSInstanceList = [constants.CA_INSTANCE_NAME, + constants.KRA_INSTANCE_NAME, + constants.OCSP_INSTANCE_NAME, + constants.TKS_INSTANCE_NAME, + constants.TPS_INSTANCE_NAME] + for Instance in DSInstanceList: + ret = master_ds._RemoveInstance(Instance) + assert ret == True + multihost.master.log.info('Remove Directory Server instances from Clone') + clone_ds = DSInstance[1] + DSInstanceList = [constants.CLONECA_INSTANCE_NAME, + constants.CLONEKRA_INSTANCE_NAME, + constants.CLONEOCSP_INSTANCE_NAME, + constants.CLONETKS_INSTANCE_NAME, + constants.CLONETPS_INSTANCE_NAME] + for Instance in DSInstanceList: + ret = clone_ds._RemoveInstance(Instance) + assert ret == True diff --git a/tests/dogtag/pytest/cli/installation/Test_sharedInstance.py b/tests/dogtag/pytest/cli/installation/Test_sharedInstance.py new file mode 100644 index 000000000..3428fda39 --- /dev/null +++ b/tests/dogtag/pytest/cli/installation/Test_sharedInstance.py @@ -0,0 +1,140 @@ +from pkilib.common.libdirsrv2 import DirSrv +from pkilib.common.wrapper import W_DirSrv +from pkilib.common.factory import PkiTools +import ConfigParser +import tempfile +import os +import shlex +import time +import socket +import pytest + +@pytest.fixture(scope='function') +def TempFile(request): + (tmp_cfg_fd, tmp_cfg_file_path) = tempfile.mkstemp() + os.close(tmp_cfg_fd) + def RemoveTempFile(): + print("Removing %r" %(tmp_cfg_file_path)) + os.remove(tmp_cfg_file_path) + request.addfinalizer(RemoveTempFile) + return tmp_cfg_file_path + +@pytest.fixture(scope='function') +def DSInstance(InstanceName): + a = W_DirSrv() + a._CreateInstance(InstanceName) + ldap_port = a.__dict__['DSLdapPort'] + #def teardown_DirSrvInstance(): + # print("Removing Instance %s" % (DSInstance)) + # a._RemoveInstance(request.param) + #request.addfinalizer(teardown_DirSrvInstance) + return ldap_port + +class TestSharedTomcat(object): + """ Install subsystems sharing same tomcat and Directory Server Instances """ + def test_InstallCA(self, TempFile): + """ Install CA with it's own tomcat instance to be shared with other subsystems """ + ldap_port = DSInstance('FoobarCA') + caconfig = ConfigParser.RawConfigParser() + caconfig.optionxform = str + caconfig.set("DEFAULT", "pki_instance_name", 'Foobar1') + caconfig.set("DEFAULT", "pki_https_port", 8443) + caconfig.set("DEFAULT", "pki_http_port", 8080) + caconfig.set("DEFAULT", "pki_token_password", 'Secret123') + caconfig.set("DEFAULT", "pki_admin_password", 'Secret123') + caconfig.set("DEFAULT", "pki_hostname", 'pki3.example.org') + caconfig.set("DEFAULT", "pki_security_domain_name", "Example Org") + caconfig.set("DEFAULT", "pki_security_domain_password", 'Secret123') + caconfig.set("DEFAULT", "pki_client_dir", "/opt/Foobar1") + caconfig.set("DEFAULT", "pki_client_pkcs12_password", "Secret123") + caconfig.set("DEFAULT", "pki_backup_keys", "True") + caconfig.set("DEFAULT", "pki_backup_password", "Secret123") + caconfig.add_section('Tomcat') + caconfig.set("Tomcat", "pki_ajp_port", "8009") + caconfig.set("Tomcat", "pki_tomcat_server", "8005") + caconfig.add_section("CA") + caconfig.set("CA", "pki_import_admin_cert", "False") + caconfig.set("CA", "pki_ds_hostname", "localhost") + caconfig.set("CA", "pki_ds_ldap_port", ldap_port) + caconfig.set("CA", "pki_ds_password", "Secret123") + + with open(TempFile, "wb") as f: + caconfig.write(f) + + cmd = "pkispawn -s CA -f %s -vv" % (TempFile) + args = shlex.split(cmd) + stdout, stderr, return_code = PkiTools.Execute(args) + assert return_code == 0 + time.sleep(5) + + def test_InstallKRA(self, TempFile): + """ Install KRA sharing Tomcat Instance of CA """ + ldap_port = DSInstance('FoobarKRA') + caconfig = ConfigParser.RawConfigParser() + caconfig.optionxform = str + caconfig.set("DEFAULT", "pki_instance_name", 'Foobar1') + caconfig.set("DEFAULT", "pki_https_port", 8443) + caconfig.set("DEFAULT", "pki_http_port", 8080) + caconfig.set("DEFAULT", "pki_token_password", 'Secret123') + caconfig.set("DEFAULT", "pki_admin_password", 'Secret123') + caconfig.set("DEFAULT", "pki_security_domain_hostname", 'pki3.example.org') + caconfig.set("DEFAULT", "pki_security_domain_https_port", "8443") + caconfig.set("DEFAULT", "pki_security_domain_user", "caadmin") + caconfig.set("DEFAULT", "pki_security_domain_password", "Secret123") + caconfig.set("DEFAULT", "pki_client_dir", "/opt/Foobar1") + caconfig.set("DEFAULT", "pki_client_pkcs12_password", "Secret123") + caconfig.set("DEFAULT", "pki_client_database_password", "Secret123") + caconfig.set("DEFAULT", "pki_backup_keys", "True") + caconfig.set("DEFAULT", "pki_backup_password", "Secret123") + caconfig.add_section('Tomcat') + caconfig.set("Tomcat", "pki_ajp_port", "8009") + caconfig.set("Tomcat", "pki_tomcat_server", "8005") + caconfig.add_section("KRA") + caconfig.set("KRA", "pki_import_admin_cert", "True") + caconfig.set("KRA", "pki_ds_hostname", "localhost") + caconfig.set("KRA", "pki_ds_ldap_port", ldap_port) + caconfig.set("KRA", "pki_ds_password", "Secret123") + + with open(TempFile, "wb") as f: + caconfig.write(f) + + cmd = "pkispawn -s KRA -f %s -vv" % (TempFile) + args = shlex.split(cmd) + stdout, stderr, return_code = PkiTools.Execute(args) + assert return_code == 0 + + def test_InstallOCSP(self, TempFile): + """ Install OCSP sharing Tomcat Instance of CA """ + ldap_port = DSInstance('FoobarOCSP') + caconfig = ConfigParser.RawConfigParser() + caconfig.optionxform = str + caconfig.set("DEFAULT", "pki_instance_name", 'Foobar1') + caconfig.set("DEFAULT", "pki_https_port", 8443) + caconfig.set("DEFAULT", "pki_http_port", 8080) + caconfig.set("DEFAULT", "pki_token_password", 'Secret123') + caconfig.set("DEFAULT", "pki_admin_password", 'Secret123') + caconfig.set("DEFAULT", "pki_security_domain_hostname", 'pki3.example.org') + caconfig.set("DEFAULT", "pki_security_domain_https_port", "8443") + caconfig.set("DEFAULT", "pki_security_domain_user", "caadmin") + caconfig.set("DEFAULT", "pki_security_domain_password", "Secret123") + caconfig.set("DEFAULT", "pki_client_dir", "/opt/Foobar1") + caconfig.set("DEFAULT", "pki_client_pkcs12_password", "Secret123") + caconfig.set("DEFAULT", "pki_client_database_password", "Secret123") + caconfig.set("DEFAULT", "pki_backup_keys", "True") + caconfig.set("DEFAULT", "pki_backup_password", "Secret123") + caconfig.add_section('Tomcat') + caconfig.set("Tomcat", "pki_ajp_port", "8009") + caconfig.set("Tomcat", "pki_tomcat_server", "8005") + caconfig.add_section("OCSP") + caconfig.set("OCSP", "pki_import_admin_cert", "True") + caconfig.set("OCSP", "pki_ds_hostname", "localhost") + caconfig.set("OCSP", "pki_ds_ldap_port", ldap_port) + caconfig.set("OCSP", "pki_ds_password", "Secret123") + + with open(TempFile, "wb") as f: + caconfig.write(f) + + cmd = "pkispawn -s OCSP -f %s -vv" % (TempFile) + args = shlex.split(cmd) + stdout, stderr, return_code = PkiTools.Execute(args) + assert return_code == 0 diff --git a/tests/dogtag/pytest/cli/installation/conftest.py b/tests/dogtag/pytest/cli/installation/conftest.py new file mode 100644 index 000000000..902d4f8b1 --- /dev/null +++ b/tests/dogtag/pytest/cli/installation/conftest.py @@ -0,0 +1,78 @@ +from pytest_multihost import make_multihost_fixture +from pkilib.common.mh_wrapper import W_DirSrv +from pkilib.common.Qe_class import QeConfig +import pytest +import tempfile +import os + +@pytest.fixture(scope='session') +def session_multihost(request): + mh = make_multihost_fixture( + request, + descriptions = + [ + { + 'type': 'cs', + 'hosts': + { + 'master': 1, + 'clone' : 1 + } + }, + ], + config_class=QeConfig) + mh.domain = mh.config.domains[0] + [mh.master] = mh.domain.hosts_by_role('master') + [mh.clone] = mh.domain.hosts_by_role('clone') + return mh + +@pytest.fixture(scope="class") +def DSInstance(session_multihost, request): + master_ds_inst = W_DirSrv(session_multihost.master) + clone_ds_inst = W_DirSrv(session_multihost.clone) + return (master_ds_inst, clone_ds_inst) + +@pytest.fixture(scope="class") +def multihost(session_multihost, DSInstance, request): + if hasattr(request.cls(), 'class_setup'): + request.cls().class_setup(session_multihost, DSInstance) + request.addfinalizer(lambda: request.cls().class_teardown(session_multihost, DSInstance)) + return session_multihost + +@pytest.fixture(scope="class") +def TempFile(request): + (tmp_cfg_fd, tmp_cfg_file_path) = tempfile.mkstemp() + os.close(tmp_cfg_fd) + def Remove_TempFile(): + print("Removing %r" %(tmp_cfg_file_path)) + os.remove(tmp_cfg_file_path) + request.addfinalizer(Remove_TempFile) + return tmp_cfg_file_path + + + +@pytest.fixture(scope="session",autouse=True) +def setup_session(request, session_multihost): + tp = TestPrep(session_multihost) + tp.setup() + def teardown_session(): + tp.teardown() + request.addfinalizer(teardown_session) + +class TestPrep(object): + def __init__(self, multihost): + self.multihost = multihost + + def setup(self): + print("\n............Session Setup...............") + self.multihost.master.run_command(['mkdir', '/root/multihost_tests']) + self.multihost.clone.run_command(['mkdir', '/root/multihost_tests']) + self.multihost.master.run_command(['touch', '/root/multihost_tests/env.sh']) + self.multihost.clone.run_command(['touch', '/root/multihost_tests/env.sh']) + + def teardown(self): + print("\n............Session Ends.................") + self.multihost.master.run_command(['rm', '-f', '/root/multihost_tests/env.sh']) + self.multihost.clone.run_command(['rm', '-f','/root/multihost_tests/env.sh']) + self.multihost.master.run_command(['rmdir', '/root/multihost_tests']) + self.multihost.clone.run_command(['rmdir', '/root/multihost_tests']) diff --git a/tests/dogtag/pytest/cli/installation/constants.py b/tests/dogtag/pytest/cli/installation/constants.py new file mode 100644 index 000000000..a3a85a6ae --- /dev/null +++ b/tests/dogtag/pytest/cli/installation/constants.py @@ -0,0 +1,90 @@ +#common to all subsystems +CLIENT_PKCS12_PASSWORD='Secret123' +BACKUP_PASSWORD = 'Secret123' +#CA Instance +CA_HTTPS_PORT = 8443 +CA_HTTP_PORT = 8080 +CA_AJP_PORT = 8009 +CA_TOMCAT_PORT = 8005 +CA_CLIENT_DIR = '/opt/FoobarCA' +CA_INSTANCE_NAME = 'FoobarCA' +SECURITY_DOMAIN_PASSWORD = 'Secret123' +CA_PASSWORD = 'Secret123' +CA_SECURITY_DOMAIN_NAME = 'Foobar Org' +CA_ADMIN_USERNAME = 'caadmin' +#KRA Instance +KRA_INSTANCE_NAME = 'FoobarKRA' +KRA_HTTPS_PORT = 12443 +KRA_HTTP_PORT = 12080 +KRA_AJP_PORT = 12009 +KRA_TOMCAT_PORT = 12005 +KRA_PASSWORD = 'Secret123' +KRA_CLIENT_DIR = '/opt/FoobarKRA' +#OCSP Instance +OCSP_INSTANCE_NAME = 'FoobarOCSP' +OCSP_HTTPS_PORT = 14443 +OCSP_HTTP_PORT = 14080 +OCSP_AJP_PORT = 14009 +OCSP_TOMCAT_PORT = 14005 +OCSP_PASSWORD = 'Secret123' +OCSP_CLIENT_DIR = '/opt/FoobarOCSP' +#TKS Instance +TKS_INSTANCE_NAME = 'FoobarTKS' +TKS_HTTPS_PORT = 15443 +TKS_HTTP_PORT = 15080 +TKS_AJP_PORT = 15009 +TKS_TOMCAT_PORT = 15005 +TKS_PASSWORD = 'Secret123' +TKS_CLIENT_DIR = '/opt/FoobarTKS' +#TPS instance +TPS_INSTANCE_NAME = 'FoobarTPS' +TPS_HTTPS_PORT = 16443 +TPS_HTTP_PORT = 16080 +TPS_AJP_PORT = 16009 +TPS_TOMCAT_PORT = 16005 +TPS_PASSWORD = 'Secret123' +TPS_CLIENT_DIR = '/opt/FoobarTPS' +#clone CA instance +CLONECA_HTTPS_PORT = 8443 +CLONECA_HTTP_PORT = 8080 +CLONECA_AJP_PORT = 8009 +CLONECA_TOMCAT_PORT = 8005 +CLONECA_CLIENT_DIR = '/opt/FoobarCloneCA' +CLONECA_INSTANCE_NAME = 'FoobarCloneCA' +CLONECA_PASSWORD = 'Secret123' + +#clone KRA instance +CLONEKRA_INSTANCE_NAME = 'FoobarCloneKRA' +CLONEKRA_HTTPS_PORT = 12443 +CLONEKRA_HTTP_PORT = 12080 +CLONEKRA_AJP_PORT = 12009 +CLONEKRA_TOMCAT_PORT = 12005 +CLONEKRA_PASSWORD = 'Secret123' +CLONEKRA_CLIENT_DIR = '/opt/FoobarCloneKRA' + +#clone OCSP Instance +CLONEOCSP_INSTANCE_NAME = 'FoobarCloneOCSP' +CLONEOCSP_HTTPS_PORT = 14443 +CLONEOCSP_HTTP_PORT = 14080 +CLONEOCSP_AJP_PORT = 14009 +CLONEOCSP_TOMCAT_PORT = 14005 +CLONEOCSP_PASSWORD = 'Secret123' +CLONEOCSP_CLIENT_DIR = '/opt/FoobarCloneOCSP' + +#clone TKS instance +CLONETKS_INSTANCE_NAME = 'FoobarCloneTKS' +CLONETKS_HTTPS_PORT = 15443 +CLONETKS_HTTP_PORT = 15080 +CLONETKS_AJP_PORT = 15009 +CLONETKS_TOMCAT_PORT = 15005 +CLONETKS_PASSWORD = 'Secret123' +CLONETKS_CLIENT_DIR = '/opt/FoobarCloneTKS' + +#clone TPS Instance +CLONETPS_INSTANCE_NAME = 'FoobarCloneTPS' +CLONETPS_HTTPS_PORT = 16443 +CLONETPS_HTTP_PORT = 16080 +CLONETPS_AJP_PORT = 16009 +CLONETPS_TOMCAT_PORT = 16005 +CLONETPS_PASSWORD = 'Secret123' +CLONETPS_CLIENT_DIR = '/opt/FoobarCloneTPS' diff --git a/tests/dogtag/pytest/docs/Install.rst b/tests/dogtag/pytest/docs/Install.rst new file mode 100644 index 000000000..2616f214d --- /dev/null +++ b/tests/dogtag/pytest/docs/Install.rst @@ -0,0 +1,39 @@ +Install +======= +* Certificate Services test suite uses Pytest-Multihost-plugin and shared library called `pkilib` to run the tests + +Dependencies +------------ + + 1. python-pytest-multihost + 2. pkilib-0.1 + 3. Pytest + + * Note: pkilib is only required to use any of the shared functions that have been written for Certificate Services. + currently pkilib contains classes which configure directory services. Look at the pkilib docs for more information + +Required Hosts +-------------- +* Red Hat Certificate Services tests are mostly multihosts tests, At a bare minimum you require 2 systems, where 1 system could be your +laptop/jenkins slave which contains all the necessary rpm's mentioned above, while other system would be the actual host where tests would run. + +Note: The actual system where test suite will run should have Certificate System/dogtag PKI Repos already available. + +RHEL7.2 +------- + +* Packages mentioned above can be installed from `idmqe-extras <http://cosmos.lab.eng.pnq.redhat.com/idmqe-extras/rhel/7Server/x86_64/>`_. repo.:: + + $ wget -O /etc/yum.repos.d/idmqe-extras-rhel.repo \ + <url to repo>/idmqe-extras-rhel.repo + $ yum install pkilib pytest + +Fedora 22 +--------- + +* On fedora 22, all the packages mentioned above except pkilib is available on base Fedora Channel, +Download the pkilib for Fedora 22 from `here <https://mrniranjan.fedorapeople.org/pkilib-0.1-1.fc22.noarch.rpm>_.` repo:: + + $ wget https://mrniranjan.fedorapeople.org/pkilib-0.1-1.fc22.noarch.rpm + $ dnf install pkilib-0.1.noarch.f22.rpm + $ dnf install pytest diff --git a/tests/dogtag/pytest/docs/Makefile b/tests/dogtag/pytest/docs/Makefile new file mode 100644 index 000000000..419d203a4 --- /dev/null +++ b/tests/dogtag/pytest/docs/Makefile @@ -0,0 +1,189 @@ +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext + +help: + @echo "Please use \`make <target>' where <target> is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Nexus.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Nexus.qhc" + +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/Nexus" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Nexus" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + diff --git a/tests/dogtag/pytest/docs/api.rst b/tests/dogtag/pytest/docs/api.rst new file mode 100644 index 000000000..d0f138663 --- /dev/null +++ b/tests/dogtag/pytest/docs/api.rst @@ -0,0 +1,18 @@ +pkilib +========= +* This doc documents all the shared modules and functions used for automating cli + +pkilib.common.mh_wrapper: +------------------------- +.. automodule:: pkilib.common.mh_wrapper + :members: + +pkilib.common.mh_libdirsrv +-------------------------- +.. automodule:: pkilib.common.mh_libdirsrv + :members: + +pkilib.common.Qe_class +---------------------- +.. automodule:: pkilib.common.Qe_class + :members: diff --git a/tests/dogtag/pytest/docs/conf.py b/tests/dogtag/pytest/docs/conf.py new file mode 100644 index 000000000..7086f4120 --- /dev/null +++ b/tests/dogtag/pytest/docs/conf.py @@ -0,0 +1,301 @@ +# -*- coding: utf-8 -*- +# +# pki tests documentation build configuration file, created by +# sphinx-quickstart on Thu Apr 2 23:33:29 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +def skip(app, what, name, obj, skip, options): + if name == "__init__": + return False + return skip + +def setup(app): + app.connect("autodoc-skip-member", skip) + +extensions = [ + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', + 'sphinx.ext.autodoc', +] +autoclass_content = 'both' + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'pki-tests' +copyright = u'2015, Red Hat' +author = u'Niranjan MR' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.1' +# The full version, including alpha/beta/rc tags. +release = '1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'flask' +#html_theme = 'sphinx_rtd_theme' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'pki-testsdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'pki-tests.tex', u'pki-tests Documentation', + u'Niranjan', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'nexus', u'pki-tests Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'pki-tests', u'pki-tests Documentation', + author, 'pki-tests', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + + diff --git a/tests/dogtag/pytest/docs/conftest.rst b/tests/dogtag/pytest/docs/conftest.rst new file mode 100644 index 000000000..68b3ab313 --- /dev/null +++ b/tests/dogtag/pytest/docs/conftest.rst @@ -0,0 +1,159 @@ +Conftest +======== +This doc describes pytest conftest file used to configure fixtures for using pytest-multihost plugin + +Introduction +------------- +conftest.py allows to put all the fixtures required for a test suite be placed in a file , which can be +referenced from all the tests in that directory. + +Session scoped Multihost Fixture +--------------------------------- +This function defines the session_multihost session fixture that defines +the config for the multihost object. This includes the hosts needed for +the test. This will need to change depending on how many hosts are +needed for which roles. + +- Example:: + + @pytest.fixture(scope="session") + def session_multihost(request): + """ Mulithost plugin fixture for session scope """ + mh = make_multihost_fixture( + request, + descriptions=[ + { + 'type': 'pki', + 'hosts': { + 'master': 1, + 'clone': 1, + }, + }, + ], + config_class=qe_class.QeConfig + ) + mh.domain = mh.config.domains[0] + [mh.master] = mh.domain.hosts_by_role('master') + [mh.replica] = mh.domain.hosts_by_role('clone') + return mh + +- Change hosts dictionary to match what is needed for the test suite. + +- If test suite needs only 1 master, change to:: + + 'hosts': { + 'master': 1, + }, + +- If test suite needs 1 master and 4 clients, change to:: + + 'hosts': { + 'master': 1, + 'client': 4, + }, + +Class Scoped Multihost Fixture +------------------------------ + +This function defines the multihost class fixture that will be used +by the majority of tests. This defines the class level setup and +teardown method names as class_setup and class teardown respectively. + +- Example:: + + @pytest.fixture(scope='class') + def multihost(session_multihost, request): + """ multihost plugin fixture for class scope """ + if hasattr(request.cls(), 'class_setup'): + request.cls().class_setup(session_multihost) + request.addfinalizer(lambda: request.cls().class_teardown(session_multihost)) + return session_multihost + +- This should not normally require any changes. + +Session Scoped Setup and Teardown Fixtures +------------------------------------------ + +This function defines the fixture that sets up the setup and teardown +at the session scope. This is done by running a TestPrep class method +for each function provided later in this file. + +- Example:: + + @pytest.fixture(scope="session", autouse=True) + def setup_session(request, session_multihost): + """ define fixture for session level setup """ + tp = TestPrep(session_multihost) + tp.setup() + + def teardown_session(): + """ define fixture for session level teardown """ + tp.teardown() + request.addfinalizer(teardown_session) + +- This should not normally require any changes. + +- This is needed for test suites that have setup/teardown needs by test + cases where cases are defined as separate modules. + +TestPrep Session Scoped Setup and Teardown Class +------------------------------------------------ + +This class provides the setup and teardown methods for the whole test +suite. This is needed by test suites that separate cases into separate +modules but, require common setup/teardown steps. This would be used +to add Certificate Services env setup calls for a test suite if not defined in the test +suite itself. + +- Example:: + + class TestPrep(object): + """ Session level setup/teardown class """ + def __init__(self, multihost): + + self.multihost = multihost + + def setup(self): + """ + Session level setup. + - Add code here that you want run before all modules in test suite. + - This should be teardown/cleanup code only, not test code. + """ + pass + + def teardown(self): + """ + Session level teardown + - Add code here that you want run after all modules in test suite. + - This should be teardown/cleanup code only, not test code. + """ + pass + + +- Use case would be to have setup create directories:: + + class TestPrep(object): + """ Session level setup/teardown class """ + def __init__(self, multihost): + + self.multihost = multihost + + def setup(self): + """ + Session level setup. + - Add code here that you want run before all modules in test suite. + - This should be teardown/cleanup code only, not test code. + """ + self.multihost.master.run_command(['mkdir', '/root/multihost_tests']) + self.multihost.clone.run_command(['mkdir', '/root/multihost_tests']) + + def teardown(self): + self.multihost.master.run_command(['rmdir', '/root/multihost_tests']) + self.multihost.clone.run_command(['rmdir', '/root/multihost_tests']) + + +- This is useful for normal test suites to setup env. It is run by pytest + for any level of test execution--test suite, sub-suite, or test case. + +- This could also pre-create users/groups/hosts/etc used by any/all test + cases if there are multiple sub-suite test modules. diff --git a/tests/dogtag/pytest/docs/examples.rst b/tests/dogtag/pytest/docs/examples.rst new file mode 100644 index 000000000..a13fab707 --- /dev/null +++ b/tests/dogtag/pytest/docs/examples.rst @@ -0,0 +1,52 @@ +Examples of using Multihost Plugin with Fixture for certificate Services +======================================================================== +pytest multihost plugin uses paramiko/OpenSSHTransport to connect to hosts and provides methods +to run commands and copy files. + + +Examples +-------- +* Run command remotely:: + + import pytest + + @pytest.fixture(scope='session') + def session_multihost(request): + mh = make_multihost_fixture( + request, + descriptions = + [ + { + 'type': 'cs', + 'hosts': + { + 'master': 1, + 'clone' : 1 + } + }, + ], + config_class=QeConfig) + mh.domain = mh.config.domains[0] + [mh.master] = mh.domain.hosts_by_role('master') + [mh.clone] = mh.domain.hosts_by_role('clone') + return mh + + class TestCase: + def test1(multihost): + multihost.master.run_command(['ls', '-l']) + + +* Copy files remotely:: + + class TestCase: + def test1(multihost): + #copy ca configuration file to master + multihost.master.transport.put_file(CAFile, '/tmp/ca_cfg') + +* Run a command and check results:: + + class Testcase: + def test1(multihost): + multihost.master.qerun(['pkispawn', '-s', 'CA', '-f', '/tmp/ca_cfg', '-vv'], exp_returncode=0, exp_output=expected_out) + + diff --git a/tests/dogtag/pytest/docs/index.rst b/tests/dogtag/pytest/docs/index.rst new file mode 100644 index 000000000..48fd41446 --- /dev/null +++ b/tests/dogtag/pytest/docs/index.rst @@ -0,0 +1,39 @@ +.. CS(pki) QE Test documentation master file, created by + sphinx-quickstart on Wed Sep 02 18:52:16 2015. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +IDM QE CS PyTest Documentation +=========================================== +* CS Pytest is a project designed to provide test suites for Red Hat Certificate Services and Dogtag PKI. + These tests are written in python using pytest framework. There will be primarily 3 types of tests + + * UI tests which rely on `selenium's webdrive <http://docs.seleniumhq.org/projects/webdriver/>`_.[Todo] + * CLI tests which rely on `python-multihost plugin <https://fedorahosted.org/python-pytest-multihost/>`_.[Todo] + * Legacy tests which rely on `Requests <http://www.python-requests.org/en/latest/>`_.[Todo] + + +Contents: + +.. toctree:: + :maxdepth: 2 + + Install + running + layout + multihost + examples + conftest + api + + +Additional Information +====================== +.. [#] `Python Pytest Multihost plugin <https://fedorahosted.org/python-pytest-multihost/>`_. + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/tests/dogtag/pytest/docs/layout.rst b/tests/dogtag/pytest/docs/layout.rst new file mode 100644 index 000000000..12f3de445 --- /dev/null +++ b/tests/dogtag/pytest/docs/layout.rst @@ -0,0 +1,19 @@ +layout +====== +* This doc provides layout of CS QE test suites directory. + + * pki-tests/dogtag/pytest + + * This is the main top directory under which there are subdirectories containing various shared functions required to write tests using pytest + + * pki-tests/dogtag/pytest/cli + + * This directory contains test suites for various cli's + + * pkilib/dogtag/pytest/ui + + * This directory contains test suites for Red Hat Certificate Services/Dogtag UI + + * pkilib/dogtag/pytest/api + + * This directory contain test suite for Red Hat Certificate Server/Dogtag Python api diff --git a/tests/dogtag/pytest/docs/multihost.rst b/tests/dogtag/pytest/docs/multihost.rst new file mode 100644 index 000000000..270305a55 --- /dev/null +++ b/tests/dogtag/pytest/docs/multihost.rst @@ -0,0 +1,121 @@ +Multihost Plugin +================ + +plugin setup and use +--------------------- +This doc explains how to setup a config for pytest multihost plugin for Certificate Services. This plugin takes +a description of available infrastructure and provides as a fixture to tests written in pytest. Each of hosts +in the infrastructure have certain attributes: + + * Role : Master/Clone/Replica/Slave/Root/Client + * Shortname: Shortname of the host + * Hostname: Current hostname of the system + * External Hostname: External Hostname of the system + * IP-Address: IP Address + * Domain: DNS Domain under which these systems fall under + +* Example1:: + + root_password: 'redhat' + domains: + - name: testrelm.test + type: pki + hosts: + - name: pki2 + external_hostname: pki2.testrelm.test + role: master + - name: pki3 + external_hostname: pki3.testrelm.test + role: clone + +* Fields: + + root_password: Root password of the systems , Instead of root password ssh keys can also be used. + + domains: DNS Domain name of the systems + + type: Can be of any name, + + name: DNS Name of the domain + + external_hostname: hostname used to connect to this host + + role: Role played by the specific host + +* Example2:: + + root_password: 'redhat' + domains: + - name: example.org + type: cs + hosts: + - name: pki3 + ip: 192.168.122.103 + role: master + +In the above example only single host `pki3.example.org` is defined which is playing the role of master + +* Example3:: + + root_password: 'redhat' + domains: + - name: testrelm.test + type: pki + hosts: + - name: pki1.testrelm.test + external_hostname: rhel7-1.example.org + ip: 192.168.122.101 + role: master + - name: pki2.testrelm.test + external_hostname: rhel7-2.example.org + ip: 192.168.122.102 + role: clone + - name: pki3.testrelm.test + external_hostname: rhel7-3.example.org + ip: 192.168.122.103 + role: client + +The above is an example of 3 hosts + + +fixtures +-------- + +To use the above infrastructure create fixtures specifying what is required to run the tests. For example, if the +infrastructure provides 2 clones and 2 masters, but for specific test/test suite requires 1 clone and 1 master, we create +fixture specifying the requirement. + +Example:: + + import pytest + from pytest_multihost import make_multihost_fixture + + @pytest.fixture(scope='class') + def multihost(request): + mh = make_multihost_fixture( + request, description= + [ + { + 'type': 'pki' + 'hosts': { + 'master':1, + 'clone':1 + } + }, + ], + config_class=QeConfig) + #we are requesting first domain + mh.domain = mh.config.domains[0] + [mh.master] = mh.domain.hosts_by_role('master') + [mh.clone] = mh.domain.hosts_by_role('clone') + return mh + + #use the fixture in tests + + def test1(multihost): + multihost.master.run_command(['ls', '-l']) + multihost.clone.run_command(['ls', '-l']) + + + + diff --git a/tests/dogtag/pytest/docs/running.rst b/tests/dogtag/pytest/docs/running.rst new file mode 100644 index 000000000..83776b9fb --- /dev/null +++ b/tests/dogtag/pytest/docs/running.rst @@ -0,0 +1,86 @@ +Running Tests +======= + +Prerequisites +------------- +* Functional Tests mostly written for Certificate services require multiple hosts. General naming used in this regard are: + + * master(m): Node on which we have all the subsystems installed like CA (Root), kra, ocsp, tks, tps + * clone(r): Which has clone of all the subsystems installed on Master or subca + * client(c): System from which we run pki commands + * mrc: topology with master, clone, client + * mrr: topology with master, clone, clone + * m : topology with only master + * mc: topology with only master and client + + +config +------- + + * To run multihosts tests, pickup a multihost template to use. Template files can be found in /etc/pkilib directory, They are named based on topology they represent. Naming scheme is mh_cfg_<topology>.yaml + + Example config file:: + + root_password: 'redhat' + domains: + - name: testrelm.test + type: cs + hosts: + - name: hostname1 + ip: 192.168.122.1 + role: master + - name: hostname2 + ip: 192.168.122.2 + role: clone + + Edit the config file and replace **hostname1** and **hostname2** with actual hostname. Hostname should be Fully qualified domain name. + + Set the root password of the systems under parameter **root_password** + +Executing Tests +--------------- +* To execute existing tests clone pki-tests repo and run py.test against any specific test suite directory. + + * On RHEL7.2:: + + $ git clone git://git.app.eng.bos.redhat.com/pki-tests.git + $ cd pki-tests/dogtag/pytest + $ py.test --multihost-config=<multihost-template> <test-suite-directory> + + * On Fedora 22:: + + $ git clone git://git.fedorahosted.org/pki.git + $ cd tests/dogtag/pytest + $ py.test --multihost-config=<multihost-template> <test-suite-directory> + +* Before executing any tests, it's required to create a config file as specified in `config` section. + + * Executing test suite:: + + $ cd pki-tests/dogtag/pytest/ + $ py.test --junit-xml=/tmp/junit.xml \ + --multihost-config=mh_cfg.yaml \ + -v <test_suite_dir> + + * Executing Individual Test sub-suite (module):: + + $ cd pki-tests/dogtag/pytest/ + $ py.test --junit-xml=/tmp/junit.xml \ + --multihost-config=mh_cfg.yaml \ + -v <test_suite_dir/test_module.py> + + * Executing individual Test cases.:: + + $ cd pki-tests/dogtag/pytest/ + + $ py.test --junit.xml=/tmp/junit.xml \ + --multihosts-config=mh_cfg.yaml \ + -v <test_suite_dir>/<test_module>.py::<TestClass>::<test_case> + + * Example 1: Running Installation test suite:: + + $ cd pki-tests/dogtag/pytest/installation + + $ py.test --junit.xml=/tmp/junit.xml \ + --multihosts-config=mh_cfg.yaml \ + -v installation diff --git a/tests/dogtag/pytest/legacy/a b/tests/dogtag/pytest/legacy/a new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/dogtag/pytest/legacy/a diff --git a/tests/dogtag/pytest/ui/a b/tests/dogtag/pytest/ui/a new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/dogtag/pytest/ui/a |
