Beispiel #1
0
def test_init():
    config = AuthConfig(
        secrets_location=f"/tmp/{uuid.uuid4()}",
        auth_passphrase='test_passphrase',
        enabled=False
    )
    auth.init("test_app", config)
    assert auth.private_keys == {}
    assert auth.public_keys == {}

    config.enabled = True

    with pytest.raises(FileNotFoundError):
        auth.init("test_app", config)

    config.create_keys = True
    auth.init("test_app", config)
    assert "test_app" in auth.private_keys
    assert "test_app" in auth.public_keys
    assert os.path.exists(pathlib.Path(config.secrets_location) / '.private' / 'test_app.pem')
    assert os.path.exists(pathlib.Path(config.secrets_location) / 'public' / 'test_app_pub.pem')

    config.create_keys = False
    auth.init("test_app", config)
    assert "test_app" in auth.private_keys
    assert "test_app" in auth.public_keys
Beispiel #2
0
def test_init():
    config = AuthConfig(
        secrets_location=f"/tmp/{uuid.uuid4()}",
        auth_passphrase='test_passphrase',
        enabled=False
    )
    auth.init(config)
    assert auth.private_key is None
    assert auth.public_key is None

    config.enabled = True

    with pytest.raises(FileNotFoundError):
        auth.init(config)

    config.create_keys = True
    auth.init(config)
    assert auth.private_key is not None
    assert auth.public_key is not None
    assert os.path.exists(pathlib.Path(config.secrets_location) / 'key.pem')
    assert os.path.exists(pathlib.Path(config.secrets_location) / 'key_pub.pem')

    config.create_keys = False
    auth.init(config)
    assert auth.private_key is not None
    assert auth.public_key is not None