|
| 1 | +# ***************************************************************************** |
| 2 | +# Copyright (c) 2024 IBM Corporation and other Contributors. |
| 3 | +# |
| 4 | +# All rights reserved. This program and the accompanying materials |
| 5 | +# are made available under the terms of the Eclipse Public License v1.0 |
| 6 | +# which accompanies this distribution, and is available at |
| 7 | +# http://www.eclipse.org/legal/epl-v10.html |
| 8 | +# |
| 9 | +# ***************************************************************************** |
| 10 | + |
| 11 | +from openshift import dynamic |
| 12 | +from kubernetes import config |
| 13 | +from kubernetes.client import api_client |
| 14 | +from kubernetes.dynamic.resource import ResourceInstance |
| 15 | + |
| 16 | +from mas.devops import mas |
| 17 | + |
| 18 | +dynClient = dynamic.DynamicClient( |
| 19 | + api_client.ApiClient(configuration=config.load_kube_config()) |
| 20 | +) |
| 21 | + |
| 22 | + |
| 23 | +def test_entitlement(): |
| 24 | + icrUsername = "testing-i" |
| 25 | + icrPassword = "not-a-real-password-i" |
| 26 | + |
| 27 | + secret = mas.updateIBMEntitlementKey(dynClient, "default", icrUsername, icrPassword) |
| 28 | + assert secret is not None |
| 29 | + assert isinstance(secret, ResourceInstance) |
| 30 | + assert secret.metadata.name == "ibm-entitlement" |
| 31 | + |
| 32 | + |
| 33 | +def test_entitlement_with_artifactory(): |
| 34 | + artifactoryUsername = "testing-a" |
| 35 | + artifactoryPassword = "not-a-real-password-a" |
| 36 | + |
| 37 | + icrUsername = "testing-i" |
| 38 | + icrPassword = "not-a-real-password-i" |
| 39 | + |
| 40 | + secret = mas.updateIBMEntitlementKey(dynClient, "default", icrUsername, icrPassword, artifactoryUsername, artifactoryPassword) |
| 41 | + assert secret is not None |
| 42 | + assert isinstance(secret, ResourceInstance) |
| 43 | + assert secret.metadata.name == "ibm-entitlement" |
| 44 | + |
| 45 | + |
| 46 | +def test_entitlement_alt_name(): |
| 47 | + icrUsername = "testing-i" |
| 48 | + icrPassword = "not-a-real-password-i" |
| 49 | + |
| 50 | + secret = mas.updateIBMEntitlementKey(dynClient, "default", icrUsername, icrPassword, secretName="ibm-entitlement-key") |
| 51 | + assert secret is not None |
| 52 | + assert isinstance(secret, ResourceInstance) |
| 53 | + assert secret.metadata.name == "ibm-entitlement-key" |
0 commit comments