def test_authentication(pre_reqs, registration, client1, wallet1):
    _, core_authnr, req_authnr = pre_reqs

    # Remove simple_authnr
    req_authnr._authenticators = req_authnr._authenticators[:-1]

    # Exception for unknown txn type
    op = {
        TXN_TYPE: 'random_txn_type',
        f.LEDGER_ID.nm: DOMAIN_LEDGER_ID,
        DATA: 1
    }
    # Just creating the request
    req = submitOp(wallet1, client1, op)
    with pytest.raises(NoAuthenticatorFound):
        req_authnr.authenticate(req.as_dict)

    # Empty set for query txn type
    op = {
        TXN_TYPE: GET_TXN,
        f.LEDGER_ID.nm: DOMAIN_LEDGER_ID,
        DATA: 1
    }
    # Just creating the request
    req = submitOp(wallet1, client1, op)
    assert set() == req_authnr.authenticate(req.as_dict)

    # identifier for write type
    req, new_wallet = new_client_request(None, randomString(), wallet1)
    core_authnr.addIdr(wallet1.defaultId,
                       wallet1.getVerkey(wallet1.defaultId))
    assert req_authnr.authenticate(req.as_dict) == {wallet1.defaultId, }
def test_authentication(looper, pre_reqs, registration, sdk_wallet_client,
                        sdk_pool_handle):
    _, core_authnr, req_authnr = pre_reqs

    # Remove simple_authnr
    req_authnr._authenticators = req_authnr._authenticators[:-1]

    # Exception for unknown txn type
    op = {
        TXN_TYPE: 'random_txn_type',
        f.LEDGER_ID.nm: DOMAIN_LEDGER_ID,
        DATA: 1
    }
    # Just creating the request
    req = sdk_sign_and_submit_op(looper, sdk_pool_handle, sdk_wallet_client,
                                 op)
    with pytest.raises(NoAuthenticatorFound):
        req_authnr.authenticate(req[0])

    # Empty set for query txn type
    op = {TXN_TYPE: GET_TXN, f.LEDGER_ID.nm: DOMAIN_LEDGER_ID, DATA: 1}
    # Just creating the request
    req = sdk_sign_and_submit_op(looper, sdk_pool_handle, sdk_wallet_client,
                                 op)
    assert set() == req_authnr.authenticate(req[0])

    # identifier for write type
    wh, did = sdk_wallet_client
    req = new_client_request(None, randomString(), looper, sdk_wallet_client)
    core_authnr.addIdr(
        did,
        looper.loop.run_until_complete(key_for_did(sdk_pool_handle, wh, did)))
    assert req_authnr.authenticate(json.loads(req)) == {
        did,
    }
def test_authentication(looper, pre_reqs, registration,
                        sdk_wallet_client,
                        sdk_pool_handle):
    _, core_authnr, req_authnr = pre_reqs

    # Remove simple_authnr
    req_authnr._authenticators = req_authnr._authenticators[:-1]

    # Exception for unknown txn type
    op = {
        TXN_TYPE: 'random_txn_type',
        f.LEDGER_ID.nm: DOMAIN_LEDGER_ID,
        DATA: 1
    }
    # Just creating the request
    req = sdk_sign_and_submit_op(looper, sdk_pool_handle,
                                 sdk_wallet_client, op)
    with pytest.raises(NoAuthenticatorFound):
        req_authnr.authenticate(req[0])

    # Empty set for query txn type
    op = {
        TXN_TYPE: GET_TXN,
        f.LEDGER_ID.nm: DOMAIN_LEDGER_ID,
        DATA: 1
    }
    # Just creating the request
    req = sdk_sign_and_submit_op(looper, sdk_pool_handle,
                                 sdk_wallet_client, op)
    assert set() == req_authnr.authenticate(req[0])

    # identifier for write type
    wh, did = sdk_wallet_client
    req = new_client_request(None, randomString(), looper, sdk_wallet_client)
    core_authnr.addIdr(did,
                       looper.loop.run_until_complete(key_for_did(sdk_pool_handle, wh, did)))
    assert req_authnr.authenticate(json.loads(req)) == {did, }