Example #1
0
    def test_positive_create_2(self, data):
        """@test: Create gpg key with valid name and valid gpg key via file
        import using the a new organization

        @feature: GPG Keys

        @assert: gpg key is created

        @BZ: 1172009

        """

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except CLIFactoryError as err:
            self.fail(err)

        # Can we find the new object?
        result = GPGKey().exists({'organization-id': self.org['id']},
                                 (self.search_key, new_obj[self.search_key]))

        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an exception here")
        self.assertEqual(new_obj[self.search_key],
                         result.stdout[self.search_key])
Example #2
0
    def test_positive_create_2(self, data):
        """@test: Create gpg key with valid name and valid gpg key via file
        import using the a new organization

        @feature: GPG Keys

        @assert: gpg key is created

        @BZ: 1172009

        """

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except CLIFactoryError as err:
            self.fail(err)

        # Can we find the new object?
        result = GPGKey().exists(
            {'organization-id': self.org['id']},
            (self.search_key, new_obj[self.search_key])
        )

        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")
        self.assertEqual(
            new_obj[self.search_key], result.stdout[self.search_key])
Example #3
0
    def test_negative_create_1(self, data):
        """
        @test: Create gpg key with valid name and valid gpg key via file import
        then try to create new one with same name
        @feature: GPG Keys
        @assert: gpg key is not created
        """

        # Setup data to pass to the factory
        data = data.copy()
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
Example #4
0
    def test_negative_create_1(self, data):
        """
        @test: Create gpg key with valid name and valid gpg key via file import
        then try to create new one with same name
        @feature: GPG Keys
        @assert: gpg key is not created
        """

        # Setup data to pass to the factory
        data = data.copy()
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
Example #5
0
    def test_positive_create_2(self, data):
        """
        @test: Create gpg key with valid name and valid gpg key via file import
        using the a new organization
        @feature: GPG Keys
        @assert: gpg key is created
        """

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
Example #6
0
    def test_positive_create_2(self, data):
        """
        @test: Create gpg key with valid name and valid gpg key via file import
        using the a new organization
        @feature: GPG Keys
        @assert: gpg key is created
        """

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
Example #7
0
    def test_negative_create_2(self, data):
        """
        @test: Create gpg key with valid name and no gpg key
        @feature: GPG Keys
        @assert: gpg key is not created
        """

        # Setup data to pass to create
        data = data.copy()
        data['organization-id'] = self.org['id']

        # Try to create a new object passing @data to factory method
        new_obj = GPGKey().create(data)
        self.assertNotEqual(new_obj.return_code, 0,
                            "Object should not be created")
        self.assertGreater(len(new_obj.stderr), 0,
                           "Should have raised an exception")
Example #8
0
    def test_negative_create_2(self, data):
        """
        @test: Create gpg key with valid name and no gpg key
        @feature: GPG Keys
        @assert: gpg key is not created
        """

        # Setup data to pass to create
        data = data.copy()
        data['organization-id'] = self.org['id']

        # Try to create a new object passing @data to factory method
        new_obj = GPGKey().create(data)
        self.assertNotEqual(
            new_obj.return_code, 0, "Object should not be created")
        self.assertGreater(
            len(new_obj.stderr), 0, "Should have raised an exception")
Example #9
0
    def test_negative_create_1(self, data):
        """@test: Create gpg key with valid name and valid gpg key via file
        import then try to create new one with same name

        @feature: GPG Keys

        @assert: gpg key is not created

        @BZ: 1172009

        """

        # Setup data to pass to the factory
        data = data.copy()
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except CLIFactoryError as err:
            self.fail(err)

        # Can we find the new object?
        result = GPGKey().exists(
            {'organization-id': self.org['id']},
            (self.search_key, new_obj[self.search_key])
        )

        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")
        self.assertEqual(
            new_obj[self.search_key], result.stdout[self.search_key])

        # Setup a new key file
        data['key'] = '/tmp/%s' % gen_alphanumeric()
        gpg_key = self.create_gpg_key_file()
        self.assertIsNotNone(gpg_key, 'GPG Key file must be created')
        ssh.upload_file(local_file=gpg_key, remote_file=data['key'])

        # Try to create a gpg key with the same name
        new_obj = GPGKey().create(data)
        self.assertNotEqual(
            new_obj.return_code, 0, "Object should not be created")
        self.assertGreater(
            len(new_obj.stderr), 0, "Should have raised an exception")
Example #10
0
    def test_negative_create_1(self, data):
        """@test: Create gpg key with valid name and valid gpg key via file
        import then try to create new one with same name

        @feature: GPG Keys

        @assert: gpg key is not created

        @BZ: 1172009

        """

        # Setup data to pass to the factory
        data = data.copy()
        data['organization-id'] = self.org['id']
        try:
            new_obj = make_gpg_key(data)
        except CLIFactoryError as err:
            self.fail(err)

        # Can we find the new object?
        result = GPGKey().exists({'organization-id': self.org['id']},
                                 (self.search_key, new_obj[self.search_key]))

        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an exception here")
        self.assertEqual(new_obj[self.search_key],
                         result.stdout[self.search_key])

        # Setup a new key file
        data['key'] = '/tmp/%s' % gen_alphanumeric()
        gpg_key = self.create_gpg_key_file()
        self.assertIsNotNone(gpg_key, 'GPG Key file must be created')
        ssh.upload_file(local_file=gpg_key, remote_file=data['key'])

        # Try to create a gpg key with the same name
        new_obj = GPGKey().create(data)
        self.assertNotEqual(new_obj.return_code, 0,
                            "Object should not be created")
        self.assertGreater(len(new_obj.stderr), 0,
                           "Should have raised an exception")
Example #11
0
    def test_positive_create_1(self, data):
        """
        @test: Create gpg key with valid name and valid gpg key via file import
        using the default created organization
        @feature: GPG Keys
        @assert: gpg key is created
        """

        result = Org.list()
        self.assertGreater(len(result.stdout), 0, 'No organization found')
        org = result.stdout[0]

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = org['id']

        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
Example #12
0
    def test_positive_create_1(self, data):
        """
        @test: Create gpg key with valid name and valid gpg key via file import
        using the default created organization
        @feature: GPG Keys
        @assert: gpg key is created
        """

        result = Org.list()
        self.assertGreater(len(result.stdout), 0, 'No organization found')
        org = result.stdout[0]

        # Setup data to pass to the factory
        data = data.copy()
        data['key'] = VALID_GPG_KEY_FILE_PATH
        data['organization-id'] = org['id']

        try:
            new_obj = make_gpg_key(data)
        except Exception, e:
            self.fail(e)
Example #13
0
    def test_negative_create_3(self, data):
        """
        @test: Create gpg key with invalid name and valid gpg key via
        file import
        @feature: GPG Keys
        @assert: gpg key is not created
        """

        # Setup data to pass to create
        data = data.copy()
        data['key'] = '/tmp/%s' % generate_name()
        data['organization-id'] = self.org['id']

        ssh.upload_file(local_file=VALID_GPG_KEY_FILE_PATH,
                        remote_file=data['key'])

        # Try to create a new object passing @data to factory method
        new_obj = GPGKey().create(data)
        self.assertNotEqual(new_obj.return_code, 0,
                            "Object should not be created")
        self.assertGreater(len(new_obj.stderr), 0,
                           "Should have raised an exception")
Example #14
0
    def test_negative_create_3(self, data):
        """
        @test: Create gpg key with invalid name and valid gpg key via
        file import
        @feature: GPG Keys
        @assert: gpg key is not created
        """

        # Setup data to pass to create
        data = data.copy()
        data['key'] = '/tmp/%s' % generate_name()
        data['organization-id'] = self.org['id']

        ssh.upload_file(
            local_file=VALID_GPG_KEY_FILE_PATH, remote_file=data['key'])

        # Try to create a new object passing @data to factory method
        new_obj = GPGKey().create(data)
        self.assertNotEqual(
            new_obj.return_code, 0, "Object should not be created")
        self.assertGreater(
            len(new_obj.stderr), 0, "Should have raised an exception")