Пример #1
0
def test_deactivate_license(d3e_init):

    try:
        create_prime_group(GRPNAME, USRNAME, PASSWD)
        # get subs_id
        subsObj = OthTable("subscriptions")
        subscriptions_single_rec_list = subsObj.getTableData(
            statement="ORDER BY id DESC LIMIT 1")
        subs_data = subscriptions_single_rec_list[0]
        start_subs_info = subs_data["used"]

        # get license token
        lic = Licenses()
        licInfoLst = lic.getLicenses(sub_id=subs_data["id"])
        licInfo = licInfoLst[0]
        lic_tkn = licInfo["token"]

        login(USRNAME, PASSWD)
        Headers.update(authorization='Bearer %s' % lic_tkn)
        r = client.put('deactivate', headers=Headers.get())
        assert (r.status == "200 OK")

        # check subscription
        end_subs_info_lst = subsObj.getTableData(
            statement="ORDER BY id DESC LIMIT 1")

        end_subs_info = end_subs_info_lst[0]
        assert (end_subs_info["used"] == start_subs_info - 1)

    except Exception as e:
        raise e

    return
Пример #2
0
def test_get_software_versions(d3e_init):

    try:
        create_prime_group(GRPNAME, USRNAME, PASSWD)
        login(USRNAME, PASSWD)
        r = client.get('update', headers=Headers.get())

        assert (r.status == "200 OK")

        softVerObj = OthTable("software_versions")

        software_version_rec_list = softVerObj.getTableData(
            statement="ORDER BY id DESC LIMIT 1")

        software_version_rec = software_version_rec_list[0]

        assert (r.json["minor"] == int(software_version_rec["minor"]))
        assert (r.json["major"] == int(software_version_rec["major"]))
        assert (r.json["revision"] == int(software_version_rec["revision"]))
        assert (r.json["path"] == software_version_rec["path"])

    except Exception as e:
        raise e

    return
Пример #3
0
def test_validate_d3e_token(d3e_init):

    try:
        create_prime_group(GRPNAME, USRNAME, PASSWD)
        login(USRNAME, PASSWD)
        activation_token = ACTIVATION_TOKEN
        Headers.update(authorization='Bearer %s' % activation_token)
        r = client.get('validate', headers=Headers.get())

        assert (r.status == "200 OK")

        actvtn_tkn_obj = ActivationToken()
        atInfoLst = actvtn_tkn_obj.getActivationToken(token=ACTIVATION_TOKEN)
        atInfo = atInfoLst[0]
        license_uuid = atInfo["license_uuid"]

        # get licenses data
        lic_obj = Licenses()
        licInfoLst = lic_obj.getLicenses(uuid=license_uuid)
        licInfo = licInfoLst[0]

        assert (r.json["license"] == licInfo["token"])

    except Exception as e:
        raise e

    return
Пример #4
0
def test_activation_tokens(d3e_init):

    create_prime_group(GRPNAME, USRNAME, PASSWD)
    # clear activation_tokens table
    activation_tokens_obj = OthTable("activation_tokens")
    activation_tokens_obj.deleteData(token=ACTIVATION_TOKEN)

    login(USRNAME, PASSWD)
    r = client.post('activationtokens',
                    headers=Headers.get(),
                    json={'activation_token': ACTIVATION_TOKEN})

    assert (r.status == "201 Created")

    return
Пример #5
0
def test_get_license(d3e_init):

    try:
        create_prime_group(GRPNAME, USRNAME, PASSWD)
        # get subs_id
        subsObj = OthTable("subscriptions")
        subscriptions_single_rec_list = subsObj.getTableData(
            statement="ORDER BY id DESC LIMIT 1")
        subs_data = subscriptions_single_rec_list[0]

        # get license token
        lic = Licenses()
        licInfoLst = lic.getLicenses(sub_id=subs_data["id"])
        licInfo = licInfoLst[0]
        lic_tkn = licInfo["token"]

        login(USRNAME, PASSWD)
        Headers.update(authorization='Bearer %s' % lic_tkn)
        r = client.get('license', headers=Headers.get())

        assert (r.status == "200 OK")

        # get subscription info
        subscription_info = get_subscription_info()
        subscription = subscription_info[SUB]

        assert (r.json["status"] == subscription["status"])
        assert (r.json["type"] == subscription["type"])
        expiration_seconds = (subscription["exp_timestamp"] -
                              datetime.datetime(1970, 1, 1)).total_seconds()
        assert (r.json["expiration"] == expiration_seconds)
        assert (r.json["count"] == subscription["count"])
        assert (r.json["used"] == subscription["used"])
        assert (r.json["tier"] == subscription["tier"])
        assert (r.json["recurring"] == subscription["recurring"])

    except Exception as e:
        raise e

    return
Пример #6
0
def test_activate_license(d3e_init):

    create_prime_group(GRPNAME, USRNAME, PASSWD)
    # delete license data
    license_obj = OthTable("licenses")
    license_obj.deleteTableData()

    # get activation token id
    activation_tokens_obj = OthTable("activation_tokens")
    activation_token_data_lst = activation_tokens_obj.getTableData(
        token=ACTIVATION_TOKEN)
    activation_token_data = activation_token_data_lst[0]
    activation_token_id = activation_token_data["id"]

    # get order number = subscription_id from subscriptions with max(id)
    subsObj = OthTable("subscriptions")
    subscriptions_single_rec_list = subsObj.getTableData(
        statement="ORDER BY id DESC LIMIT 1")
    subs_data = subscriptions_single_rec_list[0]
    # order_number = subscription_id
    order_number = subs_data["subscription_id"]

    login(USRNAME, PASSWD)
    r = client.put('activate',
                   headers=Headers.get(),
                   json={
                       'activationTokenId': activation_token_id,
                       'orderNumber': order_number
                   })

    assert (r.status == '201 Created')  # license data created

    try:

        # get user info
        usr = dvcUser()
        usrInfoLst = usr.getUserInfo(username=USRNAME)
        usrInfo = usrInfoLst[0]
        assert (usrInfo["stripe_cust_id"] != None)

        # get group info
        grp = dvcGroup()
        grpInfoLst = grp.getGroupInfo(name=GRPNAME)
        grpInfo = grpInfoLst[0]

        # check subscriptions table
        subscriptionObj = Subscriptions()
        sbscrptn_id = str(order_number)
        subscriptions_info_list = subscriptionObj.getSubscriptions(
            subscription_id=sbscrptn_id, user_id=usrInfo["id"])
        subscriptions_info = subscriptions_info_list[0]

        assert (subscriptions_info["count"] <= 2)
        assert (subscriptions_info["user_id"] == usrInfo["id"])
        assert (subscriptions_info["plan_id"] == plan_id_light)
        assert (subscriptions_info["subscription_id"] == sbscrptn_id)
        assert (subscriptions_info["group_id"] == grpInfo["id"])
        assert (subscriptions_info["used"] == 1)

        # check activation_token table
        #token_contents = ACTIVATION_TOKEN.split(".")
        #assert(len(token_contents) == 3)
        actvtn_tkn_obj = ActivationToken()
        atInfoLst = actvtn_tkn_obj.getActivationToken(token=ACTIVATION_TOKEN)
        atInfo = atInfoLst[0]
        assert (atInfo["activated"] == 1)

        # get activation info
        payload = jwt.decode(ACTIVATION_TOKEN,
                             D3E_ACTIVATION_KEY,
                             algorithms=JWT_DECODE_ALGORITHM)

        activation_info = {
            "expiration": payload["exp"],
            "system_serial": payload["sys"],
            "manufacturer": payload["man"],
            "model": payload["mod"],
            "computer_name": payload["cmp"]
        }

        # check liceses table
        lic = Licenses()
        licInfoLst = lic.getLicenses(group_id=grpInfo["id"],
                                     sub_id=subscriptions_info["id"])
        licInfo = licInfoLst[0]

        assert (licInfo["system_serial"] == activation_info["system_serial"])
        assert (licInfo["manufacturer"] == activation_info["manufacturer"])
        assert (licInfo["model"] == activation_info["model"])
        assert (licInfo["computer_name"] == activation_info["computer_name"])

    except Exception as e:
        raise e

    return