Projects >> katello-api >>71b95b225b9d58c7871ac82da373ba1686e27d0b

Chunk
Conflicting content
	public static final String CMD_LIST = "user list";
	public static final String CMD_DELETE = "user delete";
	public static final String CMD_ASSIGN_ROLE = "user assign_role";
<<<<<<< HEAD
	public static final String CMD_UNASSIGN_ROLE = "user unassign_role";
	public static final String CMD_LIST_ROLES = "user list_roles";
	
=======
	public static final String CMD_DELETE_USER = "user delete";
	public static final String CMD_REPORT = "user report";
>>>>>>> a8d8904f13212e743bac95981c13c83e2bf64ff3
	public static final String ERR_TEMPLATE_NOTFOUND = 
			"Could not find template [ %s ]";	
	public static final String OUT_CREATE = 
Solution content
	public static final String CMD_LIST = "user list";
	public static final String CMD_ASSIGN_ROLE = "user assign_role";
	public static final String CMD_DELETE_USER = "user delete";
	public static final String CMD_UNASSIGN_ROLE = "user unassign_role";
	public static final String CMD_LIST_ROLES = "user list_roles";
	public static final String CMD_REPORT = "user report";
	public static final String ERR_TEMPLATE_NOTFOUND = 
			"Could not find template [ %s ]";	
	public static final String OUT_CREATE = 
File
KatelloUser.java
Developer's decision
Combination
Kind of conflict
Attribute
Chunk
Conflicting content
			"Could not find template [ %s ]";	
	public static final String OUT_CREATE = 
			"Successfully created user [ %s ]";
<<<<<<< HEAD
	
	public static final String REG_USER_LIST = ".*Id:\\s+\\d+.*Username:\\s+%s.*Email:\\s+%s.*";
	public static final String REG_USER_ROLE_LIST = ".*\\d+\\s+%s.*";
=======
	public static final String OUT_DELETE =
			"Successfully deleted user [ %s ]";
	public static final String OUT_ASSIGN_ROLE =
			            "User \'%s\' assigned to role \'%s\'";
	
>>>>>>> a8d8904f13212e743bac95981c13c83e2bf64ff3

	// ** ** ** ** ** ** ** Class members
	public String username;
Solution content
	
			"Could not find template [ %s ]";	
	public static final String OUT_CREATE = 
			"Successfully created user [ %s ]";
	public static final String OUT_DELETE =
			"Successfully deleted user [ %s ]";
	public static final String OUT_ASSIGN_ROLE =
			            "User \'%s\' assigned to role \'%s\'";
	public static final String OUT_UNASSIGN_ROLE =
            "User \'%s\' unassigned from role \'%s\'";
	public static final String OUT_FIND_USER_ERROR =
			"Could not find user [ %s ]";
	
	public static final String REG_USER_LIST = ".*Id:\\s+\\d+.*Username:\\s+%s.*Email:\\s+%s.*";
	public static final String REG_USER_ROLE_LIST = ".*\\d+\\s+%s.*";
	// ** ** ** ** ** ** ** Class members
	public String username;
File
KatelloUser.java
Developer's decision
Manual
Kind of conflict
Attribute
Chunk
Conflicting content
		return cli.run();
	}
	
<<<<<<< HEAD
	public SSHCommandResult unassign_role(String role){
		opts.clear();
		opts.add(new Attribute("username", username));
		opts.add(new Attribute("role", role));
		cli = new KatelloCli(CMD_UNASSIGN_ROLE, opts);
		return cli.run();
	}
	
	public SSHCommandResult list_roles(){
		opts.clear();
		opts.add(new Attribute("username", username));
		cli = new KatelloCli(CMD_LIST_ROLES, opts);
		return cli.run();
	}
	
	public SSHCommandResult delete(){
		opts.clear();
		opts.add(new Attribute("username", this.username));
		cli = new KatelloCli(CMD_DELETE, opts);
		return cli.run();
	}
=======
	 
	public SSHCommandResult delete_user(String pName){
		 
		    opts.clear();
		    opts.add(new Attribute("username", username));
		    cli = new KatelloCli(CMD_DELETE_USER,opts);
		    return cli.run();
		     
	}
	
>>>>>>> a8d8904f13212e743bac95981c13c83e2bf64ff3

	// ** ** ** ** ** ** **
	// ASSERTS
Solution content
		return cli.run();
	}
	
	public SSHCommandResult unassign_role(String role){
		opts.clear();
		opts.add(new Attribute("username", username));
		opts.add(new Attribute("role", role));
		cli = new KatelloCli(CMD_UNASSIGN_ROLE, opts);
		return cli.run();
	}
	
	public SSHCommandResult list_roles(){
		opts.clear();
		opts.add(new Attribute("username", username));
		cli = new KatelloCli(CMD_LIST_ROLES, opts);
		return cli.run();
	}
	
	public SSHCommandResult delete(){
		opts.clear();
		opts.add(new Attribute("username", this.username));
		cli = new KatelloCli(CMD_DELETE_USER, opts);
		return cli.run();
	}

	// ** ** ** ** ** ** **
	// ASSERTS
File
KatelloUser.java
Developer's decision
Combination
Kind of conflict
Method declaration
Chunk
Conflicting content
	
	List users;

<<<<<<< HEAD
	@Test(description="create user - for default org")
=======
@Test(description="create user - for default org", enabled=true)
>>>>>>> a8d8904f13212e743bac95981c13c83e2bf64ff3
	public void test_create_DefaultOrg(){
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
Solution content
	
	List users;

	@Test(description="create user - for default org", enabled=true)
	public void test_create_DefaultOrg(){
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
File
UserTests.java
Developer's decision
Version 2
Kind of conflict
Annotation
Chunk
Conflicting content
		usr.asserts_create();
	}
	
<<<<<<< HEAD
	@Test(description = "List all users - admin should be there")
	public void test_listUsers_admin(){
		KatelloUser list_user = new KatelloUser(null,null, null, false);
		SSHCommandResult res = list_user.list();
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code");
		Assert.assertTrue(getOutput(res).contains(KatelloUser.DEFAULT_ADMIN_USER), "Check - contains: ["+KatelloUser.DEFAULT_ADMIN_USER+"]");
	}
	
	@Test(description = "List users - created", 
			dependsOnMethods={"test_create_DefaultOrg"})
	public void test_infoListUser(){
		KatelloUser list_user = createUser();
		users.add(list_user);
		
		SSHCommandResult res = list_user.list();
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user list)");
		
		for(KatelloUser user : this.users){
			String match_list = String.format(KatelloUser.REG_USER_LIST, user.username, user.email).replaceAll("\"", ""); // output not have '"' signs
			Assert.assertTrue(getOutput(res).replaceAll("\n", "").matches(match_list), "Check - user matches ["+user.username+"]");
			assert_userInfo(user); // Assertions - `user info --username %s` 
		}
	}
	
	@Test(description = "Create User and Role, assign role to user")
	public void test_assignRole(){
		
		KatelloUser user = createUser();

		KatelloUserRole role = createRole();
		
		SSHCommandResult res = user.assign_role(role.name);
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user assign_role)");
		Assert.assertEquals(getOutput(res).trim(), 
				String.format("User '%s' assigned to role '%s'", user.username, role.name));
	}
	
	@Test(description = "Create User and 2 Roles, assign roles to user and then unassign one of them. Verify that only one role is unassigned")
	public void test_unassignRole(){
		
		KatelloUser user = createUser();

		KatelloUserRole role = createRole();
		user.assign_role(role.name);
		
		KatelloUserRole role2 = createRole();
		user.assign_role(role2.name);
		
		SSHCommandResult res = user.unassign_role(role.name);
		
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user unassign_role)");
		Assert.assertEquals(getOutput(res).trim(), 
				String.format("User '%s' unassigned from role '%s'", user.username, role.name));
		
		res = user.list_roles();
		String out = getOutput(res).replaceAll("\n", "");
		
		String match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role2.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role2.name+"]");
	}
	
	@Test(description = "Create User and Roles, assign roles to user, verify list_roles shows them")
	public void test_listRoles(){
		
		KatelloUser user = createUser();

		KatelloUserRole role = createRole();
		user.assign_role(role.name);
		
		KatelloUserRole role1 = createRole();
		user.assign_role(role1.name);
		
		KatelloUserRole role2 = createRole();
		user.assign_role(role2.name);
		
		KatelloUserRole role3 = createRole();
		user.assign_role(role3.name);
		
		SSHCommandResult res = user.list_roles();
		
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user list_roles)");
		String out = getOutput(res).replaceAll("\n", "");
		
		String match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role.name+"]");
		
		match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role1.name+"]");
		
		match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role2.name+"]");
		
		match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role3.name+"]");
	}
	
	@Test(description="Delete a user", enabled=false)
	public void test_deleteUser(){
		KatelloUser user = createUser();
		
		SSHCommandResult res = user.delete();
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code");
		Assert.assertTrue(getOutput(res).contains(String.format("Successfully deleted user [ %s ]",user.username)),"Check - return string");
		
		res = user.info();
		Assert.assertEquals(res.getExitCode(), new Integer(65),"Check - return code [65]");
		Assert.assertEquals(getOutput(res).trim(), 
				String.format("Could not find user [ %s ]",user.username));
	}
	
	private void assert_userInfo(KatelloUser user){
		SSHCommandResult res;
		res = user.info();
		String match_info = String.format(KatelloUser.REG_USER_LIST,user.username,user.email).replaceAll("\"", "");
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code");
		log.finest(String.format("User (info) match regex: [%s]",match_info));
		Assert.assertTrue(getOutput(res).replaceAll("\n", "").matches(match_info), 
				String.format("User [%s] should be found in the result info",user.username));		
	}
	
	private KatelloUser createUser() {
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "usr-"+uniqueID;
		String userpass = "password";
		String usermail = username+"@localhost";
		
		KatelloUser user = new KatelloUser(username, usermail, userpass, false);
		user.create();
		
		return user;
	}
	
	private KatelloUserRole createRole() {
		String uniqueID = KatelloTestScript.getUniqueID();
		String rolename = "role-"+uniqueID;
		String descr = "role-desc";
		KatelloUserRole role = new KatelloUserRole(rolename, descr);
		role.create();
		
		return role;
	}
	
=======
	
	@Test(description="delete users - for some org provided", enabled=true)
	public void test_DeleteUserOrg(){
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "user-"+uniqueID;
		String userpass = "password";
		String usermail = username+"@localhost";
        String orgname  = "ACME_Corporation";
        String envname  = "DEV";
		KatelloUser usr = new KatelloUser(username, usermail, userpass, false, orgname,envname);
		res = usr.create();
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_CREATE+")");
		Assert.assertTrue(getOutput(res).contains(
				String.format(KatelloUser.OUT_CREATE,username)), 
				"Check - returned output string ("+KatelloUser.CMD_CREATE+")");
		
		usr.asserts_create();
		res = usr.delete_user(username);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_DELETE_USER+")");
		Assert.assertTrue(getOutput(res).contains(String.format(KatelloUser.OUT_DELETE, username)),
				                                  "Checked - returned output string ("+KatelloUser.CMD_DELETE_USER+")");
		usr.asserts_delete();
	
	}
	

	@Test(description="delete users - for default org ", enabled=true)
	public void test_DeleteUserDefaultOrg(){
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "user-"+uniqueID;
		String userpass = "password";
		String usermail = username+"@localhost";
		
		KatelloUser usr = new KatelloUser(username, usermail, userpass, false);
		res = usr.create();
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_CREATE+")");
		Assert.assertTrue(getOutput(res).contains(
				String.format(KatelloUser.OUT_CREATE,username)), 
				"Check - returned output string ("+KatelloUser.CMD_CREATE+")");
		
		usr.asserts_create();
		res = usr.delete_user(username);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_DELETE_USER+")");
		Assert.assertTrue(getOutput(res).contains(String.format(KatelloUser.OUT_DELETE, username)),
				                                  "Checked - returned output string ("+KatelloUser.CMD_DELETE_USER+")");
		usr.asserts_delete();
	
	}
	
	
	
	@Test(description="Generates User Report - pdf format", enabled=true)
	public void test_UserReport_pdf(){
		SSHCommandResult res;
		String format = "pdf";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	}
	
	@Test(description="Generates User Report - html format", enabled=true)
	public void test_UserReport_html(){
		SSHCommandResult res;
		String format = "html";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	}
	
	@Test(description="Generates User Report - default format", enabled=true)
	public void test_UserReport(){
		SSHCommandResult res;
		String format = "";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	}
	
	
	@Test(description="Generates User Report - csv format", enabled=true)
	public void test_UserReport_csv(){
		SSHCommandResult res;
		String format = "csv";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	} 
	
	@Test(description="assign roles to users", enabled=true)
	public void test_AssignUserRoles(){
		
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "user-"+uniqueID;
		String userpass = "password";
		String usermail = username+"@localhost";
		String unique_role_ID = KatelloTestScript.getUniqueID();
		String user_role_name = "user-role"+unique_role_ID;
		String role_desc = "Assigned " + user_role_name + " to user " + username; 
		KatelloUser usr = new KatelloUser(username, usermail, userpass, false);
		res = usr.create();
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_CREATE+")");
		Assert.assertTrue(getOutput(res).contains(
				String.format(KatelloUser.OUT_CREATE,username)), 
				"Check - returned output string ("+KatelloUser.CMD_CREATE+")");
		
		usr.asserts_create();
		KatelloUserRole usr_role = new KatelloUserRole(user_role_name,role_desc);
        res = usr_role.create();
        Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUserRole.CMD_CREATE+")");
        Assert.assertTrue(getOutput(res).contains(String.format(KatelloUserRole.OUT_CREATE, user_role_name)),
        		                                 "Check - returned output string ("+KatelloUserRole.CMD_CREATE+")");

        res = usr.assign_role(usr_role.name);
        Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_ASSIGN_ROLE+")");
        Assert.assertTrue(getOutput(res).contains(String.format(KatelloUser.OUT_ASSIGN_ROLE, username,user_role_name)), 
        		                                  "Check - returned output string ("+KatelloUser.CMD_ASSIGN_ROLE+")");
	
	}
	
	
>>>>>>> a8d8904f13212e743bac95981c13c83e2bf64ff3
}
Solution content
		usr.asserts_create();
	}
	

	@Test(description = "List all users - admin should be there")
	public void test_listUsers_admin(){
		KatelloUser list_user = new KatelloUser(null,null, null, false);
		SSHCommandResult res = list_user.list();
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code");
		Assert.assertTrue(getOutput(res).contains(KatelloUser.DEFAULT_ADMIN_USER), "Check - contains: ["+KatelloUser.DEFAULT_ADMIN_USER+"]");
	}
	
	@Test(description = "List users - created", 
			dependsOnMethods={"test_create_DefaultOrg"})
	public void test_infoListUser(){
		KatelloUser list_user = createUser();
		users.add(list_user);
		
		SSHCommandResult res = list_user.list();
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user list)");
		
		for(KatelloUser user : this.users){
			String match_list = String.format(KatelloUser.REG_USER_LIST, user.username, user.email).replaceAll("\"", ""); // output not have '"' signs
			Assert.assertTrue(getOutput(res).replaceAll("\n", "").matches(match_list), "Check - user matches ["+user.username+"]");
			assert_userInfo(user); // Assertions - `user info --username %s` 
		}
	}
	
	@Test(description = "delete users - for some org provided", enabled = true)
	public void test_DeleteUserOrg() {
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "user-" + uniqueID;
		String userpass = "password";
		String usermail = username + "@localhost";
		String orgname = "ACME_Corporation";
		String envname = "DEV";
		KatelloUser usr = new KatelloUser(username, usermail, userpass, false,
				orgname, envname);
		res = usr.create();
		Assert.assertTrue(res.getExitCode().intValue() == 0,
				"Check - return code (" + KatelloUser.CMD_CREATE + ")");
		Assert.assertTrue(
				getOutput(res).contains(
						String.format(KatelloUser.OUT_CREATE, username)),
				"Check - returned output string (" + KatelloUser.CMD_CREATE
						+ ")");

		usr.asserts_create();
		res = usr.delete();
		Assert.assertTrue(res.getExitCode().intValue() == 0,
				"Check - return code (" + KatelloUser.CMD_DELETE_USER + ")");
		Assert.assertTrue(
				getOutput(res).contains(
						String.format(KatelloUser.OUT_DELETE, username)),
				"Checked - returned output string ("
						+ KatelloUser.CMD_DELETE_USER + ")");
		usr.asserts_delete();

	}

	@Test(description="delete users - for default org ", enabled=true)
	public void test_DeleteUserDefaultOrg(){
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "user-"+uniqueID;
		String userpass = "password";
		String usermail = username+"@localhost";
		
		KatelloUser usr = new KatelloUser(username, usermail, userpass, false);
		res = usr.create();
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_CREATE+")");
		Assert.assertTrue(getOutput(res).contains(
				String.format(KatelloUser.OUT_CREATE,username)), 
				"Check - returned output string ("+KatelloUser.CMD_CREATE+")");
		
		usr.asserts_create();
		res = usr.delete();
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_DELETE_USER+")");
		Assert.assertTrue(getOutput(res).contains(String.format(KatelloUser.OUT_DELETE, username)),
				                                  "Checked - returned output string ("+KatelloUser.CMD_DELETE_USER+")");
		usr.asserts_delete();
	
	}
	
	
	
	@Test(description="Generates User Report - pdf format", enabled=true)
	public void test_UserReport_pdf(){
		SSHCommandResult res;
		String format = "pdf";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	}
	
	@Test(description="Generates User Report - html format", enabled=true)
	public void test_UserReport_html(){
		SSHCommandResult res;
		String format = "html";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	}
	
	@Test(description="Generates User Report - default format", enabled=true)
	public void test_UserReport(){
		SSHCommandResult res;
		String format = "";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	}
	
	
	@Test(description="Generates User Report - csv format", enabled=true)
	public void test_UserReport_csv(){
		SSHCommandResult res;
		String format = "csv";
		res = KatelloUser.report(format);
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_REPORT+")");
		
	
	} 
	
	@Test(description="assign roles to users", enabled=true)
	public void test_AssignUserRoles(){
		
		SSHCommandResult res;
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "user-"+uniqueID;
		String userpass = "password";
		String usermail = username+"@localhost";
		String unique_role_ID = KatelloTestScript.getUniqueID();
		String user_role_name = "user-role"+unique_role_ID;
		String role_desc = "Assigned " + user_role_name + " to user " + username; 
		KatelloUser usr = new KatelloUser(username, usermail, userpass, false);
		res = usr.create();
		Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_CREATE+")");
		Assert.assertTrue(getOutput(res).contains(
				String.format(KatelloUser.OUT_CREATE,username)), 
				"Check - returned output string ("+KatelloUser.CMD_CREATE+")");
		
		usr.asserts_create();
		KatelloUserRole usr_role = new KatelloUserRole(user_role_name,role_desc);
        res = usr_role.create();
        Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUserRole.CMD_CREATE+")");
        Assert.assertTrue(getOutput(res).contains(String.format(KatelloUserRole.OUT_CREATE, user_role_name)),
        		                                 "Check - returned output string ("+KatelloUserRole.CMD_CREATE+")");

        res = usr.assign_role(usr_role.name);
        Assert.assertTrue(res.getExitCode().intValue()==0, "Check - return code ("+KatelloUser.CMD_ASSIGN_ROLE+")");
	
        Assert.assertTrue(getOutput(res).contains(String.format(KatelloUser.OUT_ASSIGN_ROLE, username,user_role_name)), 
        		                                  "Check - returned output string ("+KatelloUser.CMD_ASSIGN_ROLE+")");
	
	}
	
	
	@Test(description = "Create User and Role, assign role to user")
	public void test_assignRole(){
		
		KatelloUser user = createUser();

		KatelloUserRole role = createRole();
		
		SSHCommandResult res = user.assign_role(role.name);
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user assign_role)");
		Assert.assertEquals(getOutput(res).trim(), 
				String.format(KatelloUser.OUT_ASSIGN_ROLE, user.username, role.name));
	}
	
	@Test(description = "Create User and 2 Roles, assign roles to user and then unassign one of them. Verify that only one role is unassigned")
	public void test_unassignRole(){
		
		KatelloUser user = createUser();

		KatelloUserRole role = createRole();
		user.assign_role(role.name);
		
		KatelloUserRole role2 = createRole();
		user.assign_role(role2.name);
		
		SSHCommandResult res = user.unassign_role(role.name);
		
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user unassign_role)");
		Assert.assertEquals(getOutput(res).trim(), 
				String.format(KatelloUser.OUT_UNASSIGN_ROLE, user.username, role.name));
		
		res = user.list_roles();
		String out = getOutput(res).replaceAll("\n", "");
		
		String match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role2.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role2.name+"]");
	}
	
	@Test(description = "Create User and Roles, assign roles to user, verify list_roles shows them")
	public void test_listRoles(){
		
		KatelloUser user = createUser();

		KatelloUserRole role = createRole();
		user.assign_role(role.name);
		
		KatelloUserRole role1 = createRole();
		user.assign_role(role1.name);
		
		KatelloUserRole role2 = createRole();
		user.assign_role(role2.name);
		
		KatelloUserRole role3 = createRole();
		user.assign_role(role3.name);
		
		SSHCommandResult res = user.list_roles();
		
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code (user list_roles)");
		String out = getOutput(res).replaceAll("\n", "");
		
		String match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role.name+"]");
		
		match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role1.name+"]");
		
		match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role2.name+"]");
		
		match_list = String.format(KatelloUser.REG_USER_ROLE_LIST, role.name).replaceAll("\"", ""); // output not have '"' signs
		Assert.assertTrue(out.matches(match_list), "Check - user role matches ["+role3.name+"]");
	}
	
	@Test(description="Delete a user", enabled=false)
	public void test_deleteUser(){
		KatelloUser user = createUser();
		
		SSHCommandResult res = user.delete();
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code");
		Assert.assertTrue(getOutput(res).contains(String.format(KatelloUser.OUT_DELETE,user.username)),"Check - return string");
		
		res = user.info();
		Assert.assertEquals(res.getExitCode(), new Integer(65),"Check - return code [65]");
		Assert.assertEquals(getOutput(res).trim(), 
				String.format(KatelloUser.OUT_FIND_USER_ERROR,user.username));
	}
	private void assert_userInfo(KatelloUser user){
		SSHCommandResult res;
		res = user.info();
		String match_info = String.format(KatelloUser.REG_USER_LIST,user.username,user.email).replaceAll("\"", "");
		Assert.assertEquals(res.getExitCode().intValue(), 0, "Check - return code");
		log.finest(String.format("User (info) match regex: [%s]",match_info));
		Assert.assertTrue(getOutput(res).replaceAll("\n", "").matches(match_info), 
				String.format("User [%s] should be found in the result info",user.username));		
	}
	
	private KatelloUser createUser() {
		String uniqueID = KatelloTestScript.getUniqueID();
		String username = "usr-"+uniqueID;
		String userpass = "password";
		String usermail = username+"@localhost";
		
		KatelloUser user = new KatelloUser(username, usermail, userpass, false);
		user.create();
		
		return user;
	}
	
	private KatelloUserRole createRole() {
		String uniqueID = KatelloTestScript.getUniqueID();
		String rolename = "role-"+uniqueID;
		String descr = "role-desc";
		KatelloUserRole role = new KatelloUserRole(rolename, descr);
		role.create();
		
		return role;
	}
	

}
File
UserTests.java
Developer's decision
Manual
Kind of conflict
Annotation
Method declaration