def test_change_password_to_the_same(self, customer, db_conn, ids):
        factory = AbcFactory(customer)
        customer_id = ids().customer_id
        new_pass = get_md5_password()
        cookie = get_session_id(customer, customer_id)

        factory.payload_change_password(new_pass).change_password(
            customer_id, cookies=cookie)
        resp = factory.payload_change_password(new_pass).change_password(
            customer_id, Code.BAD_REQUEST, cookies=cookie).resp

        assert_error_message(customer, resp, ErrorDictAbc.PASSWORD_UNCHANGED)
Example #2
0
 def test_logout_unauthorized(self, customer, db_conn, ids):
     customer_id = ids().customer_id
     assert_error_message(
         customer,
         AbcFactory(customer).payload_logout().logout(
             customer_id, Code.UNAUTHORIZED, unauthorised=True).resp,
         ErrorDictAbc.UNAUTHORIZED)
 def test_get_account_info_unauthorized(self, customer, db_conn, ids):
     customer_id = ids().customer_id
     assert_error_message(
         customer,
         AbcFactory(customer).get_account_info(customer_id,
                                               Code.UNAUTHORIZED,
                                               unauthorised=True).resp,
         ErrorDictAbc.UNAUTHORIZED)
Example #4
0
def get_validation_code(customer, db_conn, customerid):
    AbcFactory(customer).payload_code_generate(customerid).generate_code()
    sleep(4)
    query = db_conn.ms_sql.get_last_notification_event(event_type=50)
    if not query:
        return not_found(customer, db_conn, slr=False)
    code = query[0][1]
    return json.loads(code)["body"]["code"]
 def test_get_line_subscriptions_unauthorized(self, customer, db_conn, ids):
     ids = ids(with_rlsid=True)
     assert_error_message(
         customer,
         AbcFactory(customer).subscriptions_params().get_subscriptions(
             ids.rlsid,
             ids.customer_id,
             Code.UNAUTHORIZED,
             unauthorised=True).resp, ErrorDictAbc.UNAUTHORIZED)
 def test_change_password_unauthorized(self, customer, db_conn, ids):
     customer_id = ids().customer_id
     assert_error_message(
         customer,
         AbcFactory(customer).payload_change_password(
             get_md5_password()).change_password(customer_id,
                                                 Code.UNAUTHORIZED,
                                                 unauthorised=True).resp,
         ErrorDictAbc.UNAUTHORIZED)
Example #7
0
 def test_get_products_unauthorized(self, customer, ids):
     ids = ids(with_rlsid=True)
     assert_error_message(
         customer,
         AbcFactory(customer).products_params().get_products(
             ids.rlsid,
             ids.customer_id,
             Code.UNAUTHORIZED,
             unauthorised=True).resp, ErrorDictAbc.UNAUTHORIZED)
    def test_create_account_unauthorized(self, customer, db_conn, ids):
        customer_id = ids(without_login=True).customer_id
        user_info = db_conn.ms_sql.get_user_info_by_customer_id(customer_id)

        assert_error_message(
            customer,
            AbcFactory(customer).payload_creation(user_info).create_account(
                customer_id, Code.UNAUTHORIZED, unauthorised=True).resp,
            ErrorDictAbc.UNAUTHORIZED)
    def test_nominal_change_password(self, customer, db_conn, ids):
        customer_id = ids().customer_id
        user_data = get_login_and_pass(db_conn, customer_id)

        AbcFactory(customer).payload_change_password(
            get_md5_password()).change_password(customer_id,
                                                cookies=get_session_id(
                                                    customer, customer_id))

        assert_password_change(customer, db_conn, user_data)
 def test_get_subscriber_registration_unauthorized(self, customer, db_conn,
                                                   ids):
     ids = ids(with_registration=True)
     assert_error_message(
         customer,
         AbcFactory(customer).get_subscriber_registration(
             ids.rlsid,
             ids.customer_id,
             Code.UNAUTHORIZED,
             unauthorised=True).resp, ErrorDictAbc.UNAUTHORIZED)
Example #11
0
    def test_nominal_post_voucher(self, customer, db_conn, ids):
        ids = ids(with_balance=True, with_products=True, with_rlsid=True)
        code = get_voucher_code(customer, db_conn, ids.soc_id)
        cookies = get_session_id(customer, ids.customer_id)

        add_balance(db_conn, ids.rlsid, value=1)

        resp = AbcFactory(customer).payload_post_voucher(code[0]).post_voucher(
            ids.rlsid, ids.customer_id, cookies=cookies).resp

        assert_equals(customer, "CreditValue", float(code[1] / 100), resp.creditAdded)
Example #12
0
    def test_post_voucher_with_invalid_code(self, code, customer, db_conn, ids):
        ids = ids(with_balance=True, with_products=True, with_rlsid=True)
        cookies = get_session_id(customer, ids.customer_id)

        resp = AbcFactory(customer).payload_post_voucher(code).post_voucher(
            ids.rlsid, ids.customer_id, Code.BAD_REQUEST, cookies=cookies).resp

        if code == "":
            assert_equals(customer, "Error reason", "PARAMETER", resp.ErrorReason)
        else:
            assert_error_message(customer, resp, ErrorDictAbc.VOUCHER_WRONG_CODE)
    def test_nominal_create_account(self, customer, db_conn, ids):
        customer_id = ids(without_login=True).customer_id
        user_info = db_conn.ms_sql.get_user_info_by_customer_id(customer_id)

        client = AbcFactory(customer).payload_creation(
            user_info).create_account(customer_id)

        assert_tracking(customer, db_conn, customer_id, Code.CREATED,
                        Method.POST, Url.ACCOUNTS)
        assert_account_creation_modification(customer, db_conn, client,
                                             customer_id)
Example #14
0
    def test_get_registration_process_by_marketing_country(
            self, customer, db_conn, ids, country="QQ"):
        ids = ids(with_registration=True)
        m_country = db_conn.ms_sql.get_marketing_country(ids.rlsid)

        resp = AbcFactory(customer).get_registration_process(
            ids.rlsid, country, ids.customer_id).resp
        assert_registration_process(customer,
                                    db_conn,
                                    resp,
                                    ids.rlsid,
                                    country=country,
                                    m_country=m_country)
    def test_get_subscriber_registration_for_rlsid_without_registration(
            self, customer, db_conn, ids):
        customer_id = db_conn.rls_my_sql.self_care_customer_id()
        customer_id_with_plus = f"+{customer_id}"
        list_of_customer_id = [
            el[0] for el in db_conn.ms_sql.customer_id_with_registration()
        ]
        while customer_id_with_plus in list_of_customer_id:
            customer_id = db_conn.rls_my_sql.self_care_customer_id()
            customer_id_with_plus = f"+{customer_id}"
        rlsid = db_conn.rls_my_sql.get_slr_id_by_customer_id(customer_id)

        AbcFactory(customer).get_subscriber_registration(
            rlsid, customer_id, Code.NOT_FOUND)
    def test_post_subscription_unauthorized(self,
                                            customer,
                                            db_conn,
                                            ids,
                                            payment_type=PType.MAIN_CREDIT):
        ids = ids(with_balance=True, with_rlsid=True)
        add_balance(db_conn, ids.rlsid)
        product_id = get_product_id(customer, db_conn, ids.customer_id,
                                    payment_type)

        resp = AbcFactory(customer).payload_post_subscription(product_id, payment_type).\
            post_subscriptions(ids.rlsid, ids.customer_id, Code.UNAUTHORIZED, unauthorised=True).resp

        assert_error_message(customer, resp, ErrorDictAbc.UNAUTHORIZED)
Example #17
0
 def test_get_registration_process_unauthorized(self,
                                                customer,
                                                db_conn,
                                                ids,
                                                country="QQ"):
     ids = ids(with_rlsid=True)
     assert_error_message(
         customer,
         AbcFactory(customer).get_registration_process(
             ids.rlsid,
             country,
             ids.customer_id,
             Code.UNAUTHORIZED,
             unauthorised=True).resp, ErrorDictAbc.UNAUTHORIZED)
    def test_nominal_post_subscription_by_external_payment(
            self, customer, db_conn, ids, payment_type=PType.EXTERNAL_PAYMENT):
        ids = ids(without_login=True, check_customer=True, with_rlsid=True)
        create_account(customer, db_conn, ids.customer_id)
        product_id = get_product_id(customer, db_conn, ids.customer_id,
                                    payment_type)

        resp = AbcFactory(customer).payload_post_subscription(
            product_id, payment_type).post_subscriptions(
                ids.rlsid,
                ids.customer_id,
                cookies=get_session_id(customer, ids.customer_id)).resp

        assert_tracking(customer, db_conn, ids.customer_id, Code.OK,
                        Method.POST, Url.SUBSCRIPTIONS.format(ids.rlsid))
        assert_post_subscription(customer, resp, payment_type)
    def test_nominal_get_line_subscriptions(self, all_lines, by_status,
                                            customer, db_conn, ids):
        ids = ids(with_rlsid=True)

        client = AbcFactory(customer).subscriptions_params(
            by_status).get_subscriptions(ids.rlsid, ids.customer_id)

        assert_tracking(customer,
                        db_conn,
                        ids.customer_id,
                        Code.OK,
                        Method.GET,
                        Url.SUBSCRIPTIONS.format(ids.rlsid),
                        param=client.params.status if by_status else None)
        assert_for_get_subscriptions_tests(customer, db_conn, client,
                                           ids.customer_id, all_lines,
                                           by_status)
    def test_create_account_with_wrong_data(self, login, password, email,
                                            first_name, last_name, country,
                                            delete_empty_fields, customer,
                                            db_conn, ids):
        customer_id = ids(without_login=True).customer_id
        user_info = db_conn.ms_sql.get_user_info_by_customer_id(customer_id)

        resp = AbcFactory(customer).payload_creation(user_info, login, password, email, first_name, last_name, country).\
            create_account(customer_id, Code.BAD_REQUEST, delete_empty_fields=delete_empty_fields).resp

        assert_equals(customer, "Error reason", "INVALID_PARAMETER",
                      resp.ErrorReason)
        assert_tracking(customer,
                        db_conn,
                        customer_id,
                        Code.BAD_REQUEST,
                        Method.POST,
                        Url.ACCOUNTS,
                        by_url=True)
    def test_post_subscription_with_wrong_data(self, product_id, source,
                                               customer, payment_type, db_conn,
                                               ids):
        ids = ids(with_balance=True, with_rlsid=True)
        add_balance(db_conn, ids.rlsid)
        product_id = product_id if product_id or product_id == "" else \
            get_product_id(customer, db_conn, ids.customer_id, payment_type)

        resp = AbcFactory(customer).payload_post_subscription(product_id, payment_type, source=source).\
            post_subscriptions(ids.rlsid, ids.customer_id, Code.BAD_REQUEST, cookies=get_session_id(customer, ids.customer_id)).resp

        assert_tracking(customer,
                        db_conn,
                        ids.customer_id,
                        Code.BAD_REQUEST,
                        Method.POST,
                        Url.SUBSCRIPTIONS.format(ids.rlsid),
                        by_url=True)
        assert_equals(customer, "Error reason", "INVALID_PARAMETER",
                      resp.ErrorReason)
    def test_nominal_post_subscription_by_main_credit(self,
                                                      customer,
                                                      db_conn,
                                                      ids,
                                                      payment_type=PType.
                                                      MAIN_CREDIT):
        ids = ids(with_balance=True, with_rlsid=True)
        add_balance(db_conn, ids.rlsid)
        product_id = get_product_id(customer, db_conn, ids.customer_id,
                                    payment_type)

        resp = AbcFactory(customer).payload_post_subscription(
            product_id, payment_type).post_subscriptions(
                ids.rlsid,
                ids.customer_id,
                cookies=get_session_id(customer, ids.customer_id)).resp

        assert_tracking(customer, db_conn, ids.customer_id, Code.OK,
                        Method.POST, Url.SUBSCRIPTIONS.format(ids.rlsid))
        assert_post_subscription(customer, resp, payment_type)
Example #23
0
    def test_nominal_get_registration_process(self,
                                              country,
                                              customer,
                                              db_conn,
                                              ids,
                                              old_marketing_country=None):
        ids = ids(with_registration=True)
        marketing_country = db_conn.ms_sql.get_marketing_country(ids.rlsid)
        if marketing_country:
            old_marketing_country = marketing_country
            db_conn.ms_sql.update_marketing_country("NULL", ids.rlsid)

        resp = AbcFactory(customer).get_registration_process(
            ids.rlsid, country, ids.customer_id).resp
        assert_registration_process(
            customer,
            db_conn,
            resp,
            ids.rlsid,
            country=country,
            old_marketing_country=old_marketing_country)
    def test_nominal_post_subscription_using_bancontact_method(
            self, customer, db_conn, ids, payment_type=PType.EXTERNAL_PAYMENT):
        ids = ids(without_login=True, check_customer=True, with_rlsid=True)
        create_account(customer, db_conn, ids.customer_id)
        product_id = get_product_id(customer, db_conn, ids.customer_id,
                                    payment_type)

        resp = AbcFactory(customer).payload_post_subscription(product_id, payment_type, payment_method="BANCONTACT").\
            post_subscriptions(ids.rlsid, ids.customer_id, cookies=get_session_id(customer, ids.customer_id)).resp

        assert_tracking(customer, db_conn, ids.customer_id, Code.OK,
                        Method.POST, Url.SUBSCRIPTIONS.format(ids.rlsid))
        assert_post_subscription(customer, resp, payment_type)

        # Finish payment using UI
        finish_bancontact_payment(customer, resp["paymentForm"]["url"])
        query = db_conn.ms_sql.get_registration_process_type(
            f"+{ids.customer_id}")
        customer.logger.assert_fail(query, "No registration process in db",
                                    db_conn.ms_sql.last_query)
        assert_equals(customer, "state", "TEMPORARY_REGISTERED",
                      query["State"])
Example #25
0
    def test_nominal_get_products(self,
                                  by_rlsid,
                                  by_category,
                                  by_parent_product,
                                  by_channel,
                                  customer,
                                  db_conn,
                                  ids,
                                  category=None,
                                  parent_product=None,
                                  channel=None,
                                  channel_dict=None,
                                  category_dict=None):
        ids = ids(with_rlsid=True)

        if by_category:
            category_dict = get_random_product_category()
            category = category_dict["name"]
        elif by_parent_product:
            category_dict = {"name": "Add-on", "category_id": 7}
            category = category_dict["name"]
            parent_product = db_conn.rls_my_sql.get_random_external_id_for_parent_product(
                ids.customer_id, category_dict["category_id"])
        elif by_channel:
            channel_dict = get_random_channel()
            channel = channel_dict["value"]

        resp = AbcFactory(customer).products_params(category, parent_product,
                                                    channel).get_products(
                                                        ids.rlsid,
                                                        ids.customer_id).resp

        assert_for_get_products_tests(customer, db_conn, ids.customer_id, resp,
                                      category_dict, parent_product,
                                      channel_dict, by_rlsid, by_category,
                                      by_parent_product)
 def test_nominal_get_account_info(self, customer, db_conn, ids):
     customer_id = ids().customer_id
     resp = AbcFactory(customer).get_account_info(customer_id).resp
     assert_tracking(customer, db_conn, customer_id, Code.OK, Method.GET,
                     Url.ACCOUNTS_INFO)
     assert_not_none(customer, "iccid", resp.iccid)
Example #27
0
 def test_nominal_generate_validation_code(self, customer, ids):
     ids = ids(without_login=True)
     AbcFactory(customer).payload_code_generate(ids.customer_id).generate_code()
Example #28
0
 def test_generate_validation_code_with_invalid_customer_id(self, customer):
     assert_error_message(customer, AbcFactory(customer).payload_code_generate(INVALID_CLIENTID).generate_code(
         Code.NOT_FOUND).resp, ErrorDictAbc.CLIENTID_NOT_FOUND)
Example #29
0
    def test_post_voucher_unauthorized(self, customer, db_conn, ids):
        ids = ids(with_balance=True, with_products=True, with_rlsid=True)
        code = get_voucher_code(customer, db_conn, ids.soc_id)

        assert_error_message(customer, AbcFactory(customer).payload_post_voucher(code[0]).post_voucher(
            ids.rlsid, ids.customer_id, Code.UNAUTHORIZED, unauthorised=True).resp, ErrorDictAbc.UNAUTHORIZED)
Example #30
0
 def test_nominal_logout(self, empty_token, customer, db_conn, ids):
     customer_id = ids().customer_id
     AbcFactory(customer).payload_logout(db_conn.ms_sql.get_device_token(),
                                         empty_token).logout(customer_id)