use of rhsm.data.Org in project rhsm-qe by RedHatQE.
the class SubscriptionManagerCLITestScript method getRegisterCredentialsDataAsListOfLists.
/**
* @return List of [String username, String password, String org]
*/
protected List<List<Object>> getRegisterCredentialsDataAsListOfLists() throws Exception {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (!isSetupBeforeSuiteComplete)
return ll;
// when the candlepin server is not standalone, then we usually don't have access to the candlepin api paths to query the users, so let's use the input parameters
if (!sm_serverType.equals(CandlepinType.standalone)) {
for (String username : sm_clientUsernames) {
String password = sm_clientPasswordDefault;
// get the orgs for this username/password
// List<Org> orgs = clienttasks.getOrgs(username,password); // fails when: You must first accept Red Hat's Terms and conditions. Please visit https://www.redhat.com/wapps/ugc
List<Org> orgs = Org.parse(clienttasks.orgs_(username, password, null, null, null, null, null, null).getStdout());
// reveals when: You must first accept Red Hat's Terms and conditions. Please visit https://www.redhat.com/wapps/ugc
if (orgs.isEmpty())
orgs.add(new Org("null", "Null"));
// append a username and password for each org the user belongs to
for (Org org : orgs) {
ll.add(Arrays.asList(new Object[] { username, password, org.orgKey }));
}
}
return ll;
}
// Notes...
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users | python -mjson.tool
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users/testuser1 | python -mjson.tool
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users/testuser1/owners | python -mjson.tool
// get all of the candlepin users
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users | python -mjson.tool
JSONArray jsonUsers = new JSONArray(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/users"));
for (int i = 0; i < jsonUsers.length(); i++) {
JSONObject jsonUser = (JSONObject) jsonUsers.get(i);
// Candlepin Users
// {
// "created": "2011-09-23T14:42:25.924+0000",
// "hashedPassword": "e3e80f61a902ceca245e22005dffb4219ac1c5f7",
// "id": "8a90f8c63296bc55013296bcc4040005",
// "superAdmin": true,
// "updated": "2011-09-23T14:42:25.924+0000",
// "username": "admin"
// },
// Katello Users...
// {
// "created_at": "2011-09-24T01:29:02Z",
// "disabled": false,
// "helptips_enabled": true,
// "id": 1,
// "own_role_id": 4,
// "page_size": 25,
// "password": "07a1dacc4f283e817c0ba353bd1452de49ce5723b2b7f56f6ee2f1f400a974b360f98acb90b630c7fa411f692bdb4c5cdd0f4b916efcf3c77e7cd0453446b185TS0YtS0uRjY0UznEsx7JqGIpEM1vEfIrBSNGdnXkFdkxsDhjmyFINBJVvkCTxeC7",
// "updated_at": "2011-09-24T01:29:02Z",
// "username": "admin"
// },
// Boolean isSuperAdmin = jsonUser.getBoolean("superAdmin");
String username = jsonUser.getString("username");
String password = sm_clientPasswordDefault;
if (username.equals(sm_serverAdminUsername))
password = sm_serverAdminPassword;
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=741961 - jsefler 9/29/2011
if (username.equals("anonymous")) {
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "741961";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("Ignoring the presence of user '" + username + "'. No automated testing with this user will be executed.");
continue;
}
}
// END OF WORKAROUND
// get the user's owners
// curl -k -u testuser1:password https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users/testuser1/owners | python -mjson.tool
JSONArray jsonUserOwners = new JSONArray(CandlepinTasks.getResourceUsingRESTfulAPI(username, password, sm_serverUrl, "/users/" + username + "/owners"));
for (int j = 0; j < jsonUserOwners.length(); j++) {
JSONObject jsonOwner = (JSONObject) jsonUserOwners.get(j);
// {
// "contentPrefix": null,
// "created": "2011-07-01T06:39:58.740+0000",
// "displayName": "Snow White",
// "href": "/owners/snowwhite",
// "id": "8a90f8c630e46c7e0130e46ce114000a",
// "key": "snowwhite",
// "parentOwner": null,
// "updated": "2011-07-01T06:39:58.740+0000",
// "upstreamUuid": null
// }
String owner = jsonOwner.getString("key");
// String username, String password, String owner
ll.add(Arrays.asList(new Object[] { username, password, owner }));
}
// don't forget that some users (for which no owners are returned) probably have READ_ONLY permission to their orgs
if (jsonUserOwners.length() == 0) {
ll.add(Arrays.asList(new Object[] { username, password, null }));
}
// minimize the number of dataProvided rows (useful during automated testcase development)
if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
break;
}
return ll;
}
use of rhsm.data.Org in project rhsm-qe by RedHatQE.
the class OrgsTests method testOrgsWithCredentials.
// Test methods ***********************************************************************
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27119", "RHEL7-51361" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager: run the orgs module with valid user credentials and verify the expected organizations are listed", groups = { "Tier2Tests", "blockedByBug-719739", "blockedByBug-1254353", /*is a duplicate of*/
"blockedByBug-1254349" }, dataProvider = "getCredentialsForOrgsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testOrgsWithCredentials(String username, String password, List<Org> expectedOrgs) {
log.info("Testing subscription-manager orgs module using username=" + username + " password=" + password + " and expecting orgs=" + expectedOrgs + " ...");
// use subscription-manager to get the organizations for which the user has access
SSHCommandResult orgsResult = clienttasks.orgs_(username, password, null, null, null, null, null, null);
// when the expectedOrgs is empty, there is a special message, assert it
if (expectedOrgs.isEmpty()) {
// Assert.assertEquals(orgsResult.getStdout().trim(), String.format("%s cannot register to any organizations.", username), "Special message when the expectedOrgs is empty."); // Bug 903298 - String Update: "Register to" -> "Register with"
Assert.assertEquals(orgsResult.getStdout().trim(), String.format("%s cannot register with any organizations.", username), "Special message when the expectedOrgs is empty.");
}
// parse the actual Orgs from the orgsResult
List<Org> actualOrgs = Org.parse(orgsResult.getStdout());
// assert that all of the expectedOrgs are included in the actualOrgs
for (Org expectedOrg : expectedOrgs) {
Assert.assertTrue(actualOrgs.contains(expectedOrg), "The list of orgs returned by subscription-manager for user '" + username + "' includes expected org: " + expectedOrg);
}
Assert.assertEquals(actualOrgs.size(), expectedOrgs.size(), "The number of orgs returned by subscription-manager for user '" + username + "'.");
}
use of rhsm.data.Org in project rhsm-qe by RedHatQE.
the class OrgsTests method getCredentialsForOrgsDataAsListOfLists.
protected List<List<Object>> getCredentialsForOrgsDataAsListOfLists() throws JSONException, Exception {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (!isSetupBeforeSuiteComplete)
return ll;
// Notes...
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users | python -mjson.tool
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users/testuser1 | python -mjson.tool
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users/testuser1/owners | python -mjson.tool
// get all of the candlepin users
// curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users | python -mjson.tool
JSONArray jsonUsers = new JSONArray(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/users"));
for (int i = 0; i < jsonUsers.length(); i++) {
JSONObject jsonUser = (JSONObject) jsonUsers.get(i);
// {
// "created": "2011-07-01T06:40:00.951+0000",
// "hashedPassword": "05557a2aaec7cb676df574d2eb080691949a6752",
// "id": "8a90f8c630e46c7e0130e46ce9b70020",
// "superAdmin": false,
// "updated": "2011-07-01T06:40:00.951+0000",
// "username": "minnie"
// }
Boolean isSuperAdmin = jsonUser.getBoolean("superAdmin");
String username = jsonUser.getString("username");
String password = sm_clientPasswordDefault;
if (username.equals(sm_serverAdminUsername))
password = sm_serverAdminPassword;
// get the user's owners
// curl -k -u testuser1:password https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/users/testuser1/owners | python -mjson.tool
JSONArray jsonUserOwners = new JSONArray(CandlepinTasks.getResourceUsingRESTfulAPI(username, password, sm_serverUrl, "/users/" + username + "/owners"));
List<Org> orgs = new ArrayList<Org>();
for (int j = 0; j < jsonUserOwners.length(); j++) {
JSONObject jsonOwner = (JSONObject) jsonUserOwners.get(j);
// {
// "contentPrefix": null,
// "created": "2011-07-01T06:39:58.740+0000",
// "displayName": "Snow White",
// "href": "/owners/snowwhite",
// "id": "8a90f8c630e46c7e0130e46ce114000a",
// "key": "snowwhite",
// "parentOwner": null,
// "updated": "2011-07-01T06:39:58.740+0000",
// "upstreamUuid": null
// }
String orgKey = jsonOwner.getString("key");
String orgName = jsonOwner.getString("displayName");
orgs.add(new Org(orgKey, orgName));
}
// String username, String password, List<Org> orgs
ll.add(Arrays.asList(new Object[] { username, password, orgs }));
}
return ll;
}
Aggregations