Skip to content

Commit

Permalink
test: Use SCA to register
Browse files Browse the repository at this point in the history
  • Loading branch information
m-horky committed Jul 16, 2024
1 parent 5529ef7 commit f55a42b
Showing 1 changed file with 27 additions and 59 deletions.
86 changes: 27 additions & 59 deletions test/check-subscriptions
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,29 @@ import testvm

# candlepin on the services image has a lot of demo data preloaded
# useful info/commands:
# Login: doc password: password
# org: snowwhite
# login: huey
# password: password
# organizations: admin, snowwhite, donallduck
#
# Login: admin password: admin
# org: admin
# login: duey
# password: password
# org: donaldduck
#
# of those, only the 'donaldduck' organization is in SCA mode
#
# product certificates are installed onto the test machine to make it possible
# to use those products; few sample products are used in the tests, because of
# the different subscriptions for doc and admin, see the PRODUCT_* variables
# the different subscriptions for users, see the PRODUCT_* variables
#
# to use the candlepin image on a test machine, either add the certificate or
# allow insecure connections (/etc/rhsm/rhsm.conf -> "insecure = 1")
#
# $IP is the ip of the candlepin machine
#
# add an activation key to a pool:
# curl --insecure --request POST --user admin:admin \
# curl --insecure --request POST --user huey:password \
# https://$IP:8443/candlepin/activation_keys/ff80808155ca50b10155ca50cd280010/pools/ff80808155ca50b10155ca51f04607e5
# register with: activation key "awesome_os_pool" and org "admin"
# register with: activation key "awesome_os_pool" and org "donaldduck"
#
# in order to get the right ids for the activation key and pool, see
# ACTIVATION_KEY_SCRIPT
Expand Down Expand Up @@ -80,12 +84,12 @@ import sys
import json
import requests
data = requests.get(sys.argv[1] + "/activation_keys", auth=("admin", "admin")).json()
data = requests.get(sys.argv[1] + "/activation_keys", auth=("huey", "password")).json()
key = [
e["id"] for e in data if e["name"] == "awesome_os_pool" and e["owner"]["displayName"] == "Admin Owner"
][0]
data = requests.get(sys.argv[1] + "/pools", auth=("admin", "admin")).json()
data = requests.get(sys.argv[1] + "/pools", auth=("huey", "password")).json()
pool = [
e["id"]
for e in data
Expand All @@ -95,7 +99,7 @@ pool = [
][0]
key_url = sys.argv[1] + "/activation_keys/{key}/pools/{pool}".format(key=key, pool=pool)
requests.post(key_url, auth=("admin", "admin"))
requests.post(key_url, auth=("huey", "password"))
"""

# fmt: off
Expand Down Expand Up @@ -224,7 +228,7 @@ class TestSubscriptions(SubscriptionsCase):
# enter server and incorrect login data
b.set_val("#subscription-register-url", "custom")
b.set_input_text("#subscription-register-url-custom", CANDLEPIN_URL)
b.set_input_text("#subscription-register-username", "doc")
b.set_input_text("#subscription-register-username", "huey")
b.set_input_text("#subscription-register-password", "wrongpass")

# Do not try to connect to insights
Expand All @@ -245,7 +249,7 @@ class TestSubscriptions(SubscriptionsCase):
b.wait_not_in_text("body", "Invalid credentials")

# wait for message that we need to specify our org
b.wait_in_text("body", "User doc is member of more organizations, but no organization was selected")
b.wait_in_text("body", "User huey is member of more organizations, but no organization was selected")

# now specify the org
b.set_input_text("#subscription-register-org", "snowwhite")
Expand All @@ -256,7 +260,7 @@ class TestSubscriptions(SubscriptionsCase):
# old error should disappear
with b.wait_timeout(60):
b.wait_not_in_text(
"body", "User doc is member of more organizations, but no organization was selected"
"body", "User huey is member of more organizations, but no organization was selected"
)

# dialog should disappear
Expand Down Expand Up @@ -296,7 +300,7 @@ class TestSubscriptions(SubscriptionsCase):
# make sure we have an activation key on the target machine
machine_python(self.machine, ACTIVATION_KEY_SCRIPT, CANDLEPIN_URL)
b.set_input_text("#subscription-register-key", "awesome_os_pool")
b.set_input_text("#subscription-register-org", "admin")
b.set_input_text("#subscription-register-org", "donaldduck")

dialog_register_button_sel = "footer .pf-m-primary"
b.click(dialog_register_button_sel)
Expand All @@ -320,42 +324,6 @@ class TestSubscriptions(SubscriptionsCase):
# find another one that isn't subscribed too
self.wait_subscription(PRODUCT_SHARED, False)

def testRegisterWithoutAutoAttach(self):
b = self.browser

self.login_and_go("/subscriptions")

# wait until we can open the registration dialog
register_button_sel = "button:contains('Register')"
b.click(register_button_sel)

b.wait_visible("#subscription-register-url")

# enter server and correct login data
b.set_val("#subscription-register-url", "custom")
b.set_input_text("#subscription-register-url-custom", CANDLEPIN_URL)
b.set_input_text("#subscription-register-username", "doc")
b.set_input_text("#subscription-register-password", "password")
b.set_input_text("#subscription-register-org", "snowwhite")

b.click("#subscription-auto-attach-use")

dialog_register_button_sel = "footer .pf-m-primary"
b.click(dialog_register_button_sel)

# dialog should disappear
with b.wait_timeout(60):
b.wait_not_present(dialog_register_button_sel)

# this product should not be subscribed ATM, because auto-attach was skipped
self.wait_subscription(PRODUCT_SHARED, False)

b.click("button:contains('Auto-attach')")

# find another one that is subscribed
with b.wait_timeout(60):
self.wait_subscription(PRODUCT_SHARED, True)

def testUnpriv(self):
self.machine.execute("useradd junior; echo junior:foobar | chpasswd")
self.login_and_go("/subscriptions", user="junior")
Expand All @@ -376,9 +344,9 @@ class TestSubscriptions(SubscriptionsCase):

b.set_val("#subscription-register-url", "custom")
b.set_input_text("#subscription-register-url-custom", CANDLEPIN_URL)
b.set_input_text("#subscription-register-username", "admin")
b.set_input_text("#subscription-register-password", "admin")
b.set_input_text("#subscription-register-org", "admin")
b.set_input_text("#subscription-register-username", "huey")
b.set_input_text("#subscription-register-password", "password")
b.set_input_text("#subscription-register-org", "donaldduck")

# Do not try to connect to insights
b.set_checked("#subscription-insights", False)
Expand Down Expand Up @@ -436,9 +404,9 @@ class TestSubscriptions(SubscriptionsCase):

b.set_val("#subscription-register-url", "custom")
b.set_input_text("#subscription-register-url-custom", CANDLEPIN_URL)
b.set_input_text("#subscription-register-username", "admin")
b.set_input_text("#subscription-register-password", "admin")
b.set_input_text("#subscription-register-org", "admin")
b.set_input_text("#subscription-register-username", "huey")
b.set_input_text("#subscription-register-password", "password")
b.set_input_text("#subscription-register-org", "donaldduck")
b.set_checked("#subscription-insights", True)
dialog_register_button_sel = "footer .pf-m-primary"
b.click(dialog_register_button_sel)
Expand Down Expand Up @@ -496,9 +464,9 @@ class TestSubscriptionsPackages(SubscriptionsCase, PackageCase):

b.set_val("#subscription-register-url", "custom")
b.set_input_text("#subscription-register-url-custom", CANDLEPIN_URL)
b.set_input_text("#subscription-register-username", "admin")
b.set_input_text("#subscription-register-password", "admin")
b.set_input_text("#subscription-register-org", "admin")
b.set_input_text("#subscription-register-username", "huey")
b.set_input_text("#subscription-register-password", "password")
b.set_input_text("#subscription-register-org", "donaldduck")
b.set_checked("#subscription-insights", True)
b.wait_visible('.pf-c-modal-box__body:contains("The insights-client package will be installed")')
b.click("footer button.apply")
Expand Down

0 comments on commit f55a42b

Please sign in to comment.