Ejemplo n.º 1
0
def test_generate_random_key():
    """
    Test Random key
    """
    from automagica.activities import generate_random_key

    # Generate a random key
    key = generate_random_key()

    assert type(key) is bytes
Ejemplo n.º 2
0
def test_encrypt_text_with_key():
    """
    Test Encrypt text
    """
    from automagica.activities import (
        generate_random_key,
        encrypt_text_with_key,
    )

    # Generate a random key
    key = generate_random_key()
    # Encrypt text with this key
    outcome = encrypt_text_with_key("Sample text", key)

    assert type(outcome) is bytes
Ejemplo n.º 3
0
def test_decrypt_text_with_key():
    """
    Test Decrypt text
    """
    from automagica.activities import (
        generate_random_key,
        encrypt_text_with_key,
        decrypt_text_with_key,
    )

    # Generate a random key
    key = generate_random_key()
    # Encrypt text with generated key
    encrypted_text = encrypt_text_with_key("Sample text", key)
    # Decrypt text with same key
    decrypted_text = decrypt_text_with_key(encrypted_text, key)

    assert "Sample text" == decrypted_text
Ejemplo n.º 4
0
def test_encrypt_file_with_key():
    """
    Test Encrypt file
    """
    from automagica.activities import (
        generate_random_key,
        make_text_file,
        encrypted_file,
    )

    # Generate a random key
    key = generate_random_key()

    # Create a text file to illustrate file encryption
    text_file_path = make_text_file()

    # Encrypt the text file
    encrypted_file = encrypt_file_with_key(text_file_path, key=key)

    assert Path(encrypted_file).is_file()
Ejemplo n.º 5
0
def test_cryptography_activities():
    """
    Test scenario to test encrypting and decrypting activities
    """
    from automagica.activities import (
        generate_random_key,
        encrypt_text_with_key,
        decrypt_text_with_key,
    )

    # Generate a random key
    key = generate_random_key()

    # Encrypt text with generated key
    encrypted_text = encrypt_text_with_key("Testing", key)

    # Decrypt text with same key
    decrypted_text = decrypt_text_with_key(encrypted_text, key)

    assert decrypted_text == "Testing"
Ejemplo n.º 6
0
def test_decrypt_file_with_key():
    """
    Test Decrypt file
    """
    from automagica.activities import (
        generate_random_key,
        make_text_file,
        encrypt_file_with_key,
        decrypt_file_with_key,
    )

    # Generate a random key
    key = generate_random_key()

    # Create a text file to encrypt file
    text_file_path = make_text_file()

    # Encrypt the text file
    encrypted_text_file = encrypt_file_with_key(text_file_path, key=key)

    # Decrypt the newly encrypted file
    decrypted_file = decrypt_file_with_key(encrypted_text_file, key=key)

    assert Path(decrypted_file).is_file()