Beispiel #1
0
def test_Vault_invalid_namespace(vault_pcw, monkeypatch):
    def with_errors(*args, **kargs):
        return MockResponse({'errors': ['bla CLEMIX', 'blub']},
                            status_code=404)

    monkeypatch.setattr(requests, "post", mock_post)
    monkeypatch.setattr(requests, 'get', with_errors)

    az = AzureCredential("does_not_exists")
    with pytest.raises(ConnectionError):
        az.getData()
Beispiel #2
0
def test_AzureCredential(vaultSetup):
    az = AzureCredential(namespace)
    assert az.getAuthExpire() is None
    az.revoke()
    assert az.isClientTokenExpired() is True
    assert az.isExpired() is True

    client_id = az.getData()['client_id']
    assert client_id == az.getData()['client_id']
    assert az.getAuthExpire() > datetime.today()

    az.renew()
    assert client_id != az.getData()['client_id']
    az.revoke()
Beispiel #3
0
def test_Vault_revoke(vaultSetup, monkeypatch):
    global leases

    az = AzureCredential(namespace)
    az.getData()
    leases = list()
    az.revoke()

    az = AzureCredential(namespace)
    az.getData()
    monkeypatch.setattr(requests, 'post', lambda *args, **kwargs: 1 / 0)
    az.revoke()
    assert az.auth_json is None
    assert az.client_token is None
    assert az.client_token_expire is None
Beispiel #4
0
def test_AzureCredential(monkeypatch):
    set_pcw_ini()
    monkeypatch.setattr(requests, "post", mock_post)
    monkeypatch.setattr(requests, "get", mock_get)

    az = AzureCredential(namespace)
    assert az.getAuthExpire() is None
    az.revoke()
    assert az.isClientTokenExpired() is True
    assert az.isExpired() is True

    client_id = az.getData()['client_id']
    assert client_id == az.getData()['client_id']
    assert az.getAuthExpire() > datetime.today()

    az.renew()
    assert client_id != az.getData()['client_id']
    az.revoke()