示例#1
0
def credentials_secret(secret_name,
                       namespace,
                       username,
                       password=None,
                       verbose=False):
    """Create a CA credentials secret.

    Args:
        secret_name (str): Name of secret.
        namespace (str): Namespace for secret to be located.
        username (str): Username for credentials secret.
        password (str): Password for credentials secret.
        verbose (bool): Verbosity. False by default.

    Returns:
        dict: Secret data including "CA_USERNAME" and "CA_PASSWORD"
    """
    try:
        secret_data = secret_read(secret_name, namespace, verbose=verbose)
        # Check that the ID stored is the same as Orderer name
        assert username == secret_data["CA_USERNAME"]
        if password:
            assert password == secret_data["CA_PASSWORD"]
    except ApiException:
        # Get relevant variables
        if not password:
            password = rand_string(24)
        secret_data = {"CA_USERNAME": username, "CA_PASSWORD": password}
        secret_create(secret_data, secret_name, namespace)
    return secret_data
示例#2
0
 def test_rand_string_(self):
     a_string = rand_string(24)
     assert len(a_string) == 24
示例#3
0
 def test_rand_string(self):
     a_string = rand_string(16)
     assert len(a_string) == 16
     assert set(ascii_letters + digits).intersection(set(a_string))
     assert not set(punctuation).intersection(set(a_string))