1
0
mirror of https://github.com/quay/quay.git synced 2025-07-28 20:22:05 +03:00

marketplace: update reconciliationworker to use webCustomerId instead of ebsAccountNumber (PROJQUAY-233) (#2582)

* update reconciliationworker to use webCustomerId instead of
ebsAccountNumber

* fix reconciler where it was incorrectly using the ebsAccountNumber to
  create subscriptions
* add job to reconciler so that it reconciles different ids between the
  database and the user api
* separate skus to be used by billing and skus to be used by reconciler
This commit is contained in:
Marcus Kok
2024-01-05 16:15:37 -05:00
committed by GitHub
parent 7357e317d6
commit 1c893baba5
10 changed files with 236 additions and 118 deletions

View File

@ -8,7 +8,6 @@ import time
import unittest
from calendar import timegm
from contextlib import contextmanager
from test.helpers import assert_action_logged, check_transitive_modifications
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
from cryptography.hazmat.backends import default_backend
@ -144,6 +143,7 @@ from endpoints.api.user import (
from endpoints.building import PreparedBuild
from endpoints.webhooks import webhooks
from initdb import finished_database_for_testing, setup_database_for_testing
from test.helpers import assert_action_logged, check_transitive_modifications
from util.morecollections import AttrDict
from util.secscan.v4.fake import fake_security_scanner
@ -176,6 +176,9 @@ ORG_REPO = "orgrepo"
ORGANIZATION = "buynlarge"
SUBSCRIPTION_USER = "subscription"
SUBSCRIPTION_ORG = "subscriptionsorg"
NEW_USER_DETAILS = {
"username": "bobby",
"password": "password",
@ -5069,57 +5072,57 @@ class TestSuperUserManagement(ApiTestCase):
class TestOrganizationRhSku(ApiTestCase):
def test_bind_sku_to_org(self):
self.login(ADMIN_ACCESS_USER)
self.login(SUBSCRIPTION_USER)
self.postResponse(
resource_name=OrganizationRhSku,
params=dict(orgname=ORGANIZATION),
data={"subscription_id": 12345},
params=dict(orgname=SUBSCRIPTION_ORG),
data={"subscription_id": 12345678},
expected_code=201,
)
json = self.getJsonResponse(
resource_name=OrganizationRhSku,
params=dict(orgname=ORGANIZATION),
params=dict(orgname=SUBSCRIPTION_ORG),
)
self.assertEqual(len(json), 1)
def test_bind_sku_duplicate(self):
user = model.user.get_user(ADMIN_ACCESS_USER)
org = model.organization.get_organization(ORGANIZATION)
model.organization_skus.bind_subscription_to_org(12345, org.id, user.id)
self.login(ADMIN_ACCESS_USER)
user = model.user.get_user(SUBSCRIPTION_USER)
org = model.organization.get_organization(SUBSCRIPTION_ORG)
model.organization_skus.bind_subscription_to_org(12345678, org.id, user.id)
self.login(SUBSCRIPTION_USER)
self.postResponse(
resource_name=OrganizationRhSku,
params=dict(orgname=ORGANIZATION),
data={"subscription_id": 12345},
params=dict(orgname=SUBSCRIPTION_ORG),
data={"subscription_id": 12345678},
expected_code=400,
)
def test_bind_sku_unauthorized(self):
# bind a sku that user does not own
self.login(ADMIN_ACCESS_USER)
self.login(SUBSCRIPTION_USER)
self.postResponse(
resource_name=OrganizationRhSku,
params=dict(orgname=ORGANIZATION),
data={"subscription_id": 11111},
params=dict(orgname=SUBSCRIPTION_ORG),
data={"subscription_id": 11111111},
expected_code=401,
)
def test_remove_sku_from_org(self):
self.login(ADMIN_ACCESS_USER)
self.login(SUBSCRIPTION_USER)
self.postResponse(
resource_name=OrganizationRhSku,
params=dict(orgname=ORGANIZATION),
data={"subscription_id": 12345},
params=dict(orgname=SUBSCRIPTION_ORG),
data={"subscription_id": 12345678},
expected_code=201,
)
self.deleteResponse(
resource_name=OrganizationRhSkuSubscriptionField,
params=dict(orgname=ORGANIZATION, subscription_id=12345),
params=dict(orgname=SUBSCRIPTION_ORG, subscription_id=12345678),
expected_code=204,
)
json = self.getJsonResponse(
resource_name=OrganizationRhSku,
params=dict(orgname=ORGANIZATION),
params=dict(orgname=SUBSCRIPTION_ORG),
)
self.assertEqual(len(json), 0)