Ejemplo n.º 1
0
 def test_ns_create_new_verbose(self, mock_ns_read, mock_api, mock_print):
     # TODO: We should ideally replicate the correct API exception
     mock_ns_read.side_effect = ApiException()
     ns_create("a-namespace", verbose=True)
     mock_ns_read.assert_called_once_with("a-namespace", verbose=True)
     mock_api.create_namespace.assert_called_once()
     mock_print.assert_called_once_with('Created namespace "a-namespace"')
Ejemplo n.º 2
0
 def test_ns_create_new(self, mock_ns_read, mock_api, mock_print):
     # TODO: We should ideally replicate the correct API exception
     mock_ns_read.side_effect = ApiException()
     ns_create('a-namespace')
     mock_ns_read.assert_called_once_with('a-namespace', verbose=False)
     mock_api.create_namespace.assert_called_once()
     mock_print.assert_not_called()
Ejemplo n.º 3
0
 def test_ns_create_new(self, mock_ns_read, mock_api, mock_log):
     # TODO: We should ideally replicate the correct API exception
     mock_ns_read.side_effect = ApiException()
     ns_create("a-namespace")
     mock_ns_read.assert_called_once_with("a-namespace")
     mock_api.create_namespace.assert_called_once()
     mock_log.info.assert_called_once_with('Created namespace "a-namespace"')
Ejemplo n.º 4
0
def admin_msp(opts, msp_name, verbose=False):
    admin_namespace = get_namespace(opts, msp_name)
    ns_create(admin_namespace, verbose=verbose)

    # Get/set credentials
    admin_creds(opts, msp_name, verbose=verbose)

    # Crypto material for Admin
    create_admin(opts, msp_name, verbose=verbose)

    # Setup MSP secrets
    msp_secrets(opts, msp_name, verbose=verbose)
Ejemplo n.º 5
0
    def test_integration_qa(self):
        # Get options
        opts = load_config(self.CONFIG)

        # Save TLS of each CA in its relevant secret
        ns_create("cas")

        # TODO: Eventually we should enable getting path for multiple CAs programatically
        execute(
            (
                "kubectl -n cas create secret tls ca--tls "
                + f"--cert={self.TLS_PATH}.crt "
                + f"--key={self.TLS_PATH}.key"
            )
        )

        # TODO: There should be a more elegant way of obtaining all the releases
        releases = (
            [key for key in opts["cas"].keys()]
            + [key + "-pg" for key in opts["cas"].keys()]
            + list(opts["msps"]["AlphaMSP"]["orderers"]["nodes"].keys())
            + [
                ("cdb-" + key)
                for key in opts["msps"]["BetaMSP"]["peers"]["nodes"].keys()
            ]
            + [key for key in opts["msps"]["BetaMSP"]["peers"]["nodes"].keys()]
        )

        # Run Fabric script
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        runner_fabric(opts)

        # Delete all deployments from Helm
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        execute(f"helm delete --purge {' '.join(releases)}")

        # Delete the namespaces
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        execute("kubectl delete ns cas alpha beta")
Ejemplo n.º 6
0
def admin_msp(opts, msp_name):
    """Setup the admin MSP, by getting/setting credentials and creating/saving crypto-material.

    Args:
        opts (dict): Nephos options dict.
        msp_name (str): Name of Membership Service Provider.
    """
    admin_namespace = get_namespace(opts, msp_name)
    ns_create(admin_namespace)

    if opts["cas"]:
        # Get/set credentials (if we use a CA)
        admin_creds(opts, msp_name)
        # Crypto material for Admin
        create_admin(opts, msp_name)
    else:
        logging.info("No CAs defined in Nephos settings, ignoring Credentials")

    # Setup MSP secrets
    msp_secrets(opts, msp_name)
Ejemplo n.º 7
0
 def test_ns_create_old(self, mock_ns_read, mock_api, mock_print):
     ns_create("a-namespace")
     mock_ns_read.assert_called_once_with("a-namespace", verbose=False)
     mock_api.create_namespace.assert_not_called()
     mock_print.assert_not_called()
Ejemplo n.º 8
0
 def test_ns_create_old(self, mock_ns_read, mock_api, mock_log):
     ns_create("a-namespace")
     mock_ns_read.assert_called_once_with("a-namespace")
     mock_api.create_namespace.assert_not_called()
     mock_log.info.assert_not_called()