Exemplo n.º 1
0
    def test_positive_create_multiple_ssh_key_types(self):
        """Multiple types of ssh keys can be added to user

        :id: d1ffa908-dc86-40c8-b6f0-20650cc67046

        :steps:
            1. Create user with all the details
            2. Add multiple types of supported ssh keys, type includes
                rsa, dsa, ed25519, ecdsa

        :expectedresults: Multiple types of supported ssh keys can be added to
            user
        """
        rsa = self.gen_ssh_rsakey()
        dsa = self.data_keys['ssh_keys']['dsa']
        ecdsa = self.data_keys['ssh_keys']['ecdsa']
        ed = self.data_keys['ssh_keys']['ed']
        user = entities.User().create()
        for key in [rsa, dsa, ecdsa, ed]:
            entities.SSHKey(
                user=user,
                name=gen_string('alpha'),
                key=key
            ).create()
        user_sshkeys = entities.SSHKey(user=user).search()
        self.assertEqual(len(user_sshkeys), 4)
Exemplo n.º 2
0
    def test_positive_CRD_ssh_key(self):
        """SSH Key can be added to User

        :id: d00905f6-3a70-4e2f-a5ae-fcac18274bb7

        :steps:

            1. Create new user with all the details
            2. Add SSH key to the above user
            3. Info the above ssh key in user
            4. Delete ssh key in user

        :expectedresults: SSH key should be added to user

        :CaseImportance: Critical
        """
        user = entities.User().create()
        ssh_name = gen_string('alpha')
        ssh_key = self.gen_ssh_rsakey()
        user_sshkey = entities.SSHKey(user=user, name=ssh_name,
                                      key=ssh_key).create()
        assert ssh_name == user_sshkey.name
        assert ssh_key == user_sshkey.key
        user_sshkey.delete()
        result = entities.SSHKey(user=user).search()
        assert len(result) == 0
Exemplo n.º 3
0
    def test_positive_ssh_key_in_host_enc(self):
        """SSH key appears in host ENC output

        :id: 4b70a950-e777-4b2d-a83d-29279715fe6d

        :steps:

            1. Create user with all the details
            2. Add ssh key in above user
            3. Provision a new host from the above user
            4. Check new hosts ENC output

        :expectedresults: SSH key should be added to host ENC output

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        user = entities.User(organization=[org], location=[loc]).create()
        ssh_key = self.gen_ssh_rsakey()
        entities.SSHKey(user=user, name=gen_string('alpha'),
                        key=ssh_key).create()
        host = entities.Host(
            owner=user,
            owner_type='User',
            organization=org,
            location=loc,
        ).create()
        sshkey_updated_for_host = '{0} {1}@{2}'.format(
            ssh_key, user.login, settings.server.hostname)
        host_enc_key = host.enc()['data']['parameters']['ssh_authorized_keys']
        self.assertEqual(sshkey_updated_for_host, host_enc_key[0])
Exemplo n.º 4
0
    def test_negative_create_ssh_key(self):
        """Invalid ssh key can not be added in User Template

        :id: e924ff03-8b2c-4ab9-a054-ea491413e143

        :steps:

            1. Create new user with all the details
            2. Attempt to add invalid string as SSH Key to above user
                e.g blabla

        :expectedresults:

            1. Invalid SSH key should not be added in user
            2. Satellite returns 'Fingerprint could not be generated' error

        :CaseImportance: Critical
        """
        invalid_sshkey = gen_string('alpha', length=256)
        with self.assertRaises(HTTPError) as context:
            entities.SSHKey(user=self.user,
                            name=gen_string('alpha'),
                            key=invalid_sshkey).create()
        self.assertRegexpMatches(context.exception.response.text,
                                 'Key is invalid')
        self.assertRegexpMatches(context.exception.response.text,
                                 'Fingerprint could not be generated')
        self.assertRegexpMatches(context.exception.response.text,
                                 'Length could not be calculated')
Exemplo n.º 5
0
    def test_negative_create_invalid_length_ssh_key(self):
        """Attempt to add SSH key that has invalid length

        :id: 899f0c46-c7fe-4610-80f1-1add4a9cbc26

        :steps:

            1. Create new user with all the details
            2. Attempt to add invalid length of SSH Key to above user

        :expectedresults: Satellite should raise 'Length could not be
            calculated' error

        :CaseImportance: Critical
        """
        invalid_length_key = self.data_keys['ssh_keys']['invalid_ssh_key']
        with self.assertRaises(HTTPError) as context:
            entities.SSHKey(
                user=self.user,
                name=gen_string('alpha'),
                key=invalid_length_key
            ).create()
        self.assertRegexpMatches(
            context.exception.response.text, 'Length could not be calculated')
        self.assertNotRegexpMatches(
            context.exception.response.text,
            'Fingerprint could not be generated'
        )
Exemplo n.º 6
0
    def test_negative_create_invalid_length_ssh_key(self, create_user):
        """Attempt to add SSH key that has invalid length

        :id: 899f0c46-c7fe-4610-80f1-1add4a9cbc26

        :steps:

            1. Create new user with all the details
            2. Attempt to add invalid length of SSH Key to above user

        :expectedresults: Satellite should raise 'Length could not be
            calculated' error

        :CaseImportance: Critical
        """
        invalid_length_key = create_user['data_keys']['ssh_keys'][
            'invalid_ssh_key']
        with pytest.raises(HTTPError) as context:
            entities.SSHKey(user=create_user['user'],
                            name=gen_string('alpha'),
                            key=invalid_length_key).create()
        assert re.search('Length could not be calculated',
                         context.value.response.text)
        assert not re.search('Fingerprint could not be generated',
                             context.value.response.text)
Exemplo n.º 7
0
    def test_negative_create_ssh_key(self, create_user):
        """Invalid ssh key can not be added in User Template

        :id: e924ff03-8b2c-4ab9-a054-ea491413e143

        :steps:

            1. Create new user with all the details
            2. Attempt to add invalid string as SSH Key to above user
                e.g blabla

        :expectedresults:

            1. Invalid SSH key should not be added in user
            2. Satellite returns 'Fingerprint could not be generated' error

        :CaseImportance: Critical
        """
        invalid_sshkey = gen_string('alpha', length=256)
        with pytest.raises(HTTPError) as context:
            entities.SSHKey(user=create_user['user'],
                            name=gen_string('alpha'),
                            key=invalid_sshkey).create()
        assert re.search('Key is not a valid public ssh key',
                         context.value.response.text)
        assert re.search('Key must be in OpenSSH public key format',
                         context.value.response.text)
        assert re.search('Fingerprint could not be generated',
                         context.value.response.text)
        assert re.search('Length could not be calculated',
                         context.value.response.text)
Exemplo n.º 8
0
    def test_positive_ssh_key_in_host_enc(self, default_sat):
        """SSH key appears in host ENC output

        :id: 4b70a950-e777-4b2d-a83d-29279715fe6d

        :steps:

            1. Create user with all the details
            2. Add ssh key in above user
            3. Provision a new host from the above user
            4. Check new hosts ENC output

        :expectedresults: SSH key should be added to host ENC output

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        user = entities.User(organization=[org], location=[loc]).create()
        ssh_key = gen_ssh_keypairs()[1]
        entities.SSHKey(user=user, name=gen_string('alpha'),
                        key=ssh_key).create()
        host = entities.Host(owner=user,
                             owner_type='User',
                             organization=org,
                             location=loc).create()
        sshkey_updated_for_host = f'{ssh_key} {user.login}@{default_sat.hostname}'
        host_enc_key = host.enc()['data']['parameters']['ssh_authorized_keys']
        assert sshkey_updated_for_host == host_enc_key[0]
Exemplo n.º 9
0
    def test_positive_list_users_ssh_key(self):
        """Satellite lists users ssh keys

        :id: 8098e74a-d81e-4410-b744-435901bd70c0

        :steps:

            1. Create user with all the details
            2. Add SSH key in above user
            3. List all the ssh keys of above user

        :expectedresults: Satellite should list all the SSH keys of user

        :CaseLevel: Integration
        """
        user = entities.User().create()
        for i in range(2):
            entities.SSHKey(user=user,
                            name=gen_string('alpha'),
                            key=self.gen_ssh_rsakey()).create()
        result = entities.SSHKey(user=user).search()
        self.assertEqual(len(result), 2)
Exemplo n.º 10
0
    def test_positive_delete_ssh_key(self):
        """Satellite Admin can delete ssh key from user

        :id: 37da9052-83a7-440d-b24c-9d4458f011e3

        :steps:

            1. Create new user with all the details
            2. Add SSH Key to above user
            3. Delete the ssh-key from user

        :expectedresults: SSH key should be deleted from user

        :CaseImportance: Critical
        """
        user = entities.User().create()
        sshkey_name = gen_string('alpha')
        sshkey = entities.SSHKey(user=user,
                                 name=sshkey_name,
                                 key=self.gen_ssh_rsakey()).create()
        sshkey.delete()
        result = entities.SSHKey(user=user).search()
        self.assertEqual(len(result), 0)
Exemplo n.º 11
0
    def test_positive_create_ssh_key_super_admin(self):
        """SSH Key can be added to Super Admin user

        :id: 397eea22-759c-4cd4-bda1-0e7835566c72

        :expectedresults: SSH Key should be added to Super Admin user

        :CaseImportance: Critical
        """
        user = entities.User().search(query={'search': u'login="******"'})[0]
        ssh_name = gen_string('alpha')
        ssh_key = self.gen_ssh_rsakey()
        user_sshkey = entities.SSHKey(user=user, name=ssh_name,
                                      key=ssh_key).create()
        self.assertEqual(ssh_name, user_sshkey.name)
        self.assertEqual(ssh_key, user_sshkey.key)
Exemplo n.º 12
0
    def test_positive_create_ssh_key(self):
        """SSH Key can be added to User

        :id: d00905f6-3a70-4e2f-a5ae-fcac18274bb7

        :steps:

            1. Create new user with all the details
            2. Add SSH key to the above user

        :expectedresults: SSH key should be added to user

        :CaseImportance: Critical
        """
        ssh_name = gen_string('alpha')
        ssh_key = self.gen_ssh_rsakey()
        user_sshkey = entities.SSHKey(
            user=self.user, name=ssh_name, key=ssh_key).create()
        self.assertEqual(ssh_name, user_sshkey.name)
        self.assertEqual(ssh_key, user_sshkey.key)
Exemplo n.º 13
0
    def test_negative_create_ssh_key_with_invalid_name(self, create_user):
        """Attempt to add SSH key that has invalid name length

        :id: e1e17839-a392-45bb-bb1e-28d3cd9dba1c

        :steps:

            1. Create new user with all the details
            2. Attempt to add invalid ssh Key name to above user

        :expectedresults: Satellite should raise Name is too long assertion

        :CaseImportance: Critical
        """
        invalid_ssh_key_name = gen_string('alpha', length=300)
        with pytest.raises(HTTPError) as context:
            entities.SSHKey(user=create_user['user'],
                            name=invalid_ssh_key_name,
                            key=self.gen_ssh_rsakey()).create()
        assert re.search("Name is too long", context.value.response.text)
Exemplo n.º 14
0
    def test_positive_info_users_ssh_key(self):
        """Satellite returns info of user ssh key

        :id: 27c526b6-1008-47f8-98ac-4b2eb9b3d65e

        :steps:

            1. Create user with all the details
            2. Add SSH key in above user
            3. Info the above ssh key in user

        :expectedresults: Satellite should return information of SSH keys of
            user

        :CaseImportance: Critical
        """
        ssh_name = gen_string('alpha')
        ssh_key = self.gen_ssh_rsakey()
        user_sshkey = entities.SSHKey(
            user=self.user, name=ssh_name, key=ssh_key).create()
        self.assertEqual(ssh_name, user_sshkey.name)
        self.assertEqual(ssh_key, user_sshkey.key)