Example #1
0
    def test_positive_update_user_1(self, test_data):
        """
        @Test: Update Username in User
        @Feature: User - Positive Update
        @Steps:
        1. Create User
        2. Update User name for all variations in [1]
        @Assert: User is updated
        """

        new_obj = make_user()
        # Can we find the new object?
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])

        # Update the user name
        result = UserObj().update({'id': new_obj['id'],
                                   'firstname': test_data['firstname']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here")

        # Fetch the user again
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        user_name = result.stdout['name'].split(' ')
        self.assertEqual(
            user_name[0],
            test_data['firstname'],
            "User first name was not updated"
        )
Example #2
0
    def test_positive_update_user_2(self, test_data):
        """
        @Test: Update Login in User
        @Feature: User
        @Steps:
        1. Create User
        2. Update User login for all variations in [1]
        @Assert: User login is updated
        """

        new_obj = make_user()
        # Can we find the new object?
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['login'], result.stdout['login'])

        # Update the user login
        result = UserObj().update({'id': new_obj['id'],
                                   'login': test_data['login']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here")

        # Fetch the user again
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(
            result.stdout['login'],
            test_data['login'],
            "User login was not updated"
        )
Example #3
0
 def test_negative_delete_user_1(self, opts):
     """
     @Test: Attempt to delete internal admin user
     @Feature: User - Negative Delete
     @Steps:
     1. Attempt to delete the last admin user
     @Assert: User is not deleted
     """
     user = UserObj()
     user.katello_user = opts['login']
     user.katello_passwd = opts['password']
     result = user.delete({'login': '******'})
     self.assertTrue(result.stderr)
     self.assertNotEqual(result.return_code, 0)
     result = UserObj().exists(tuple_search=('login', 'admin'))
     self.assertTrue(result.stdout)
Example #4
0
 def test_negative_update_user_4(self, mail):
     """
     @Test: Update invalid Email Address in an User
     @Feature: User - Negative Update
     @Steps:
     1. Create User
     2. Update Email Address for all variations in [2]
     @Assert: User is not updated.  Appropriate error shown.
     """
     new_user = make_user()
     result = UserObj().update({'login': new_user['login'], 'mail': mail})
     self.assertTrue(result.stderr)
     self.assertNotEqual(result.return_code, 0)
     # check name have not changed
     updated_user = UserObj().exists(
         tuple_search=('login', new_user['login']))
     self.assertEqual(updated_user.stdout['email'], new_user['mail'])
Example #5
0
 def test_positive_delete_user_2(self, test_data):
     """
     @Test: Delete an admin user
     @Feature: User - Positive Delete
     @Steps:
     1. Create an admin user
     2. Delete the User
     @Assert: User is deleted
     """
     test_data.update({'admin': 'true'})
     user = make_user(test_data)
     self.__assert_exists(user)
     result = UserObj().delete({'login': user['login']})
     self.assertEqual(result.return_code, 0)
     self.assertEqual(len(result.stderr), 0)
     # make sure user was removed
     result = UserObj().info({'login': user['login']})
     self.assertNotEqual(result.return_code, 0)
     self.assertGreater(len(result.stderr), 0)
Example #6
0
    def test_bugzilla_1079649_2(self):
        """
        @Test: Delete a user by it's ID
        @Feature: User
        @Steps:
        1. Create User
        2. Delete the User
        @Assert: User is deleted
        @BZ: 1079649
        """

        user = make_user()
        self.__assert_exists(user)
        result = UserObj().delete({'id': user['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        # make sure user was removed
        result = UserObj().info({'login': user['login']})
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Example #7
0
 def test_negative_update_user_3(self, opts):
     """
     @Test: Update invalid Surname in an User
     @Feature: User - Negative Update
     @Steps:
     1. Create User
     2. Update Surname for all variations in [2]
     @Assert: User is not updated.  Appropriate error shown.
     """
     new_user = make_user()
     result = UserObj().update({'login': new_user['login'],
                                'lastname': opts['lastname']})
     self.assertTrue(result.stderr)
     self.assertNotEqual(result.return_code, 0)
     # check name have not changed
     updated_user = UserObj().exists(
         tuple_search=('login', new_user['login']))
     self.assertEqual(updated_user.stdout['name'], "%s %s" %
                                                   (new_user['firstname'],
                                                    new_user['lastname']))
Example #8
0
    def test_positive_update_user_4(self, test_data):
        """
        @Test: Update Email Address in User
        @Feature: User - Positive Update
        @Steps:
        1. Create User
        2. Update Email Address for all variations in [1]
        @Assert: User is updated
        """

        new_obj = make_user()
        # Can we find the new object?
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])
        self.assertEqual(result.stdout['email'], new_obj['email'])

        # Update the mail
        email = test_data['mail'] + "@example.com"
        result = UserObj().update({'id': new_obj['id'],
                                   'mail': email})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(
            len(result.stderr), 0, "There should not be an error here")

        # Fetch the user again
        result = UserObj().info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertNotEqual(result.stdout['email'], new_obj['email'])
        self.assertEqual(
            result.stdout['email'],
            email,
            "User Email was not updated"
        )
Example #9
0
 def __assert_exists(self, args):
     """
     Checks if the object that passed as args parameter really exists
     in `hammer user list --search args['login']` and has values of:
     Login,Name,Email
     """
     result = UserObj().list({'search': 'login=\"%s\"' % args['login']})
     self.assertTrue(result.return_code == 0,
                     "User search - exit code %d" %
                     result.return_code)
     self.assertTrue(result.stdout[0]['name'] ==
                     args['firstname'] + " " + args['lastname'],
                     "User search - check our value 'Name'")
     self.assertTrue(result.stdout[0]['email'] == args['mail'],
                     "User search - check our value 'Email'")
Example #10
0
 def test_negative_create_user_5(self):
     """
     @Test: Create User with blank Authorized by
     @Feature: User - Negative Create
     @Steps:
     1. Create User with blank Authorized by
     using valid Username, First Name, Surname, Email Address, Language
     @Assert: User is not created. Appropriate error shown.
     """
     options = {
         'login': generate_string("alpha", 10),
         'mail': "root@localhost",
         'auth-source-id': ''
     }
     result = UserObj().create(options)
     self.assertNotEqual(result.return_code, 0)
     self.assertTrue(result.stderr)
Example #11
0
 def test_negative_create_user_3(self, opts):
     """
     @Test: Create User with invalid Surname
     @Feature: User - Negative Create
     @Steps:
     1. Create User for all invalid Surname in [2]
     using valid Username, First Name Email Address, Language, authorized by
     @Assert: User is not created. Appropriate error shown.
     """
     options = {
         'login': generate_string("alpha", 10),
         'lastname': opts['lastname'],
         'mail': "root@localhost",
         'password': generate_string("alpha", 10),
         'auth-source-id': 1
     }
     result = UserObj().create(options)
     self.assertNotEqual(result.return_code, 0)
     self.assertTrue(result.stderr)