def make_pending_device(utoken, tenant_token=''):
    devauthm = ApiClient(deviceauth_v2.URL_MGMT)
    devauthd = ApiClient(deviceauth_v1.URL_DEVICES)

    id_data = rand_id_data()

    priv, pub = testutils.util.crypto.rsa_get_keypair()
    new_set = create_authset(devauthd, devauthm, id_data, pub, priv, utoken, tenant_token=tenant_token)

    dev = Device(new_set.did, new_set.id_data, utoken, tenant_token)

    dev.authsets.append(new_set)

    dev.status = 'pending'

    return dev
示例#2
0
def make_pending_device(utoken, num_auth_sets=1, tenant_token=""):
    devauthm = ApiClient(deviceauth_v2.URL_MGMT)
    devauthd = ApiClient(deviceauth_v1.URL_DEVICES)

    id_data = rand_id_data()

    dev = None
    for i in range(num_auth_sets):
        priv, pub = testutils.util.crypto.rsa_get_keypair()
        new_set = create_authset(
            devauthd, devauthm, id_data, pub, priv, utoken, tenant_token=tenant_token
        )

        if dev is None:
            dev = Device(new_set.did, new_set.id_data, utoken, tenant_token)

        dev.authsets.append(new_set)

    dev.status = "pending"

    return dev
示例#3
0
def make_preauthd_device(utoken):
    devauthm = ApiClient(deviceauth_v2.URL_MGMT)

    priv, pub = testutils.util.crypto.rsa_get_keypair()
    id_data = rand_id_data()

    body = deviceauth_v2.preauth_req(id_data, pub)
    r = devauthm.with_auth(utoken).call("POST", deviceauth_v2.URL_DEVICES, body)
    assert r.status_code == 201

    api_dev = get_device_by_id_data(devauthm, id_data, utoken)
    assert len(api_dev["auth_sets"]) == 1
    aset = api_dev["auth_sets"][0]

    dev = Device(api_dev["id"], id_data, pub)
    dev.authsets.append(
        Authset(aset["id"], dev.id, id_data, pub, priv, "preauthorized")
    )

    dev.status = "preauthorized"

    return dev