Esempio n. 1
0
def add_permission_to_user(user_created, perm):
    role = Role()
    created_role = ApiCrud.record_create(role)
    flter = Filter()
    flter.role_id = created_role.id
    flter.permission_ids = [perm.id]
    ApiCrud.record_create(flter)
    user_created.role_ids = [created_role.id]
    ApiCrud.record_update(user_created)
Esempio n. 2
0
def add_permission_to_user(user_created, perm):
    role = Role()
    created_role = ApiCrud.record_create(role)
    flter = Filter()
    flter.role_id = created_role.id
    flter.permission_ids = [perm.id]
    ApiCrud.record_create(flter)
    user_created.role_ids = [created_role.id]
    ApiCrud.record_update(user_created)
Esempio n. 3
0
    def test_search_key_1(self, test_data):
        """
        @feature: Organizations
        @test: Create organization and search/find it
        @assert: organization can be found
        """

        ApiCrud.record_create(test_data)
        org_res = ApiCrud.record_resolve(test_data)
        self.assertEqual(org_res.name, test_data.name)
Esempio n. 4
0
    def test_search_key_1(self, test_data):
        """
        @feature: Organizations
        @test: Create organization and search/find it
        @assert: organization can be found
        @BZ: 1072905
        """

        ApiCrud.record_create(test_data)
        org_res = ApiCrud.record_resolve(test_data)
        self.assertEqual(org_res.name, test_data.name)
Esempio n. 5
0
 def test_negative_create_2(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid label and description, name is
     whitespace
     @assert: organization is not created
     """
     try:
         ApiCrud.record_create(test_data)
         correctly_failing = False
     except ApiException:
         correctly_failing = True
     self.assertTrue(correctly_failing)
Esempio n. 6
0
 def test_negative_create_2(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid label and description, name is
     whitespace
     @assert: organization is not created
     """
     try:
         ApiCrud.record_create(test_data)
         correctly_failing = False
     except ApiException:
         correctly_failing = True
     self.assertTrue(correctly_failing)
Esempio n. 7
0
    def test_search_name_1(self, test_data):
        """
        @feature: Organizations
        @test: Create organization and search/find it
        @assert: organization can be found
        @BZ: 1072905
        """

        ApiCrud.record_create(test_data)
        query = {"search": "name=%s" % test_data.name}
        result = Organization._meta.api_class.list(json=query)
        self.assertTrue(result.ok)
        name = result.json()["results"][0]["name"]
        self.assertEqual(name, test_data.name)
Esempio n. 8
0
 def test_negative_create_3(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values, then create a new one
     with same values.
     @assert: organization is not created
     """
     ApiCrud.record_create(test_data)
     try:
         ApiCrud.record_create(test_data)
         correctly_failing = False
     except ApiException:
         correctly_failing = True
     self.assertTrue(correctly_failing)
Esempio n. 9
0
 def test_host_collections(self, test_data):
     """
     @test: Verify, that you can add host collections
     @feature: ActivationKey
     @assert: there was no system group and you have added one
     """
     acc = ApiCrud.record_create(test_data)
     self.assertEqual(len(acc.host_collections), 0)
     sg = HostCollectionDefOrg()
     sgc = ApiCrud.record_create(sg)
     r = acc._meta.api_class.add_host_collection(acc, [sgc.id])
     self.assertTrue(r.ok)
     acr = ApiCrud.record_resolve(acc)
     self.assertEqual(len(acr.host_collections), 1)
Esempio n. 10
0
 def test_negative_create_3(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values, then create a new one
     with same values.
     @assert: organization is not created
     """
     ApiCrud.record_create(test_data)
     try:
         ApiCrud.record_create(test_data)
         correctly_failing = False
     except ApiException:
         correctly_failing = True
     self.assertTrue(correctly_failing)
Esempio n. 11
0
 def test_positive_create_1(self, test_data):
     """
     @feature: ActivationKey
     @test: Try creating activation keys with valid name/label/desc
     @assert: ActivationKeyis created, sent and recieved data intersects
     """
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
Esempio n. 12
0
 def test_positive_create_1(self, test_data):
     """
     @feature: ActivationKey
     @test: Try creating activation keys with valid name/label/desc
     @assert: ActivationKeyis created, sent and recieved data intersects
     """
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
Esempio n. 13
0
 def test_positive_create_5(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid name, label and description
     @assert: organization is created
     """
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
Esempio n. 14
0
 def test_positive_create_5(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid name, label and description
     @assert: organization is created
     """
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
Esempio n. 15
0
 def test_positive_create_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid name only
     @assert: organization is created, label is auto-generated
     """
     result = ApiCrud.record_create(test_data)
     test_data.label = result.label
     self.assertIntersects(test_data, result)
Esempio n. 16
0
 def test_list_key_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization and list it
     @assert: organization is displayed/listed
     """
     org = ApiCrud.record_create(test_data)
     orgs = ApiCrud.record_list(org)
     self.assertTrue(any(org.name == ol.name for ol in orgs))
Esempio n. 17
0
 def test_positive_create_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid name only
     @assert: organization is created, label is auto-generated
     """
     result = ApiCrud.record_create(test_data)
     test_data.label = result.label
     self.assertIntersects(test_data, result)
Esempio n. 18
0
 def test_positive_create_3(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid unmatching name and label only
     @assert: organization is created, label does not match name
     """
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
     self.assertNotEqual(result.name, result.label)
Esempio n. 19
0
 def test_positive_create_3(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid unmatching name and label only
     @assert: organization is created, label does not match name
     """
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
     self.assertNotEqual(result.name, result.label)
Esempio n. 20
0
 def test_list_key_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization and list it
     @assert: organization is displayed/listed
     """
     org = ApiCrud.record_create(test_data)
     orgs = ApiCrud.record_list(org)
     self.assertTrue(any(org.name == ol.name for ol in orgs))
Esempio n. 21
0
 def test_positive_update_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then update its name
     @assert: organization name is updated
     """
     org = Organization()
     org = ApiCrud.record_create(org)
     org.name = test_data.name
     ApiCrud.record_update(org)
Esempio n. 22
0
 def test_positive_create_2(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid matching name and label only
     @assert: organization is created, label matches name
     """
     test_data.name = test_data.label
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
     self.assertEquals(result.name, result.label)
Esempio n. 23
0
 def test_positive_delete_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then delete it
     @assert: organization is deleted
     """
     t = ApiCrud.record_create(test_data)
     self.assertTrue(ApiCrud.record_exists(t))
     ApiCrud.record_remove(t)
     self.assertFalse(ApiCrud.record_exists(t))
Esempio n. 24
0
 def test_positive_delete_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then delete it
     @assert: organization is deleted
     """
     t = ApiCrud.record_create(test_data)
     self.assertTrue(ApiCrud.record_exists(t))
     ApiCrud.record_remove(t)
     self.assertFalse(ApiCrud.record_exists(t))
Esempio n. 25
0
 def test_positive_update_1(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then update its name
     @assert: organization name is updated
     """
     org = Organization()
     org = ApiCrud.record_create(org)
     org.name = test_data.name
     ApiCrud.record_update(org)
Esempio n. 26
0
 def test_positive_update_2(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then update its label
     @assert: organization label is updated
     """
     org = Organization()
     org = ApiCrud.record_create(org)
     org.label = test_data.label
     ApiCrud.record_update(org)
Esempio n. 27
0
 def test_positive_create_2(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid matching name and label only
     @assert: organization is created, label matches name
     """
     test_data.name = test_data.label
     result = ApiCrud.record_create(test_data)
     self.assertIntersects(test_data, result)
     self.assertEquals(result.name, result.label)
Esempio n. 28
0
 def test_positive_update_3(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then update its
     description
     @assert: organization description is updated
     """
     org = Organization()
     org = ApiCrud.record_create(org)
     org.description = test_data.description
     ApiCrud.record_update(org)
Esempio n. 29
0
    def test_info_key_1(self, test_data):
        """
        @feature: Organizations
        @test: Create single organization and get its info
        @assert: specific information for organization matches the
        creation values
        """

        org = ApiCrud.record_create(test_data)
        org_res = ApiCrud.record_resolve(org)
        self.assertEqual(org_res.name, test_data.name)
Esempio n. 30
0
    def test_positive_create(self, name):
        """
        @Feature: Environment - Positive Create
        @Test: Create new environment
        @Assert: Environment is created
        """

        environment = Environment(name=name)
        result = ApiCrud.record_create(environment)
        self.assertEqual(result.name, environment.name)
        self.assertTrue(ApiCrud.record_exists(environment))
Esempio n. 31
0
    def test_positive_create(self, name):
        """
        @Feature: Environment - Positive Create
        @Test: Create new environment
        @Assert: Environment is created
        """

        environment = Environment(name=name)
        result = ApiCrud.record_create(environment)
        self.assertEqual(result.name, environment.name)
        self.assertTrue(ApiCrud.record_exists(environment))
Esempio n. 32
0
 def test_positive_update_3(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then update its
     description
     @assert: organization description is updated
     """
     org = Organization()
     org = ApiCrud.record_create(org)
     org.description = test_data.description
     ApiCrud.record_update(org)
Esempio n. 33
0
    def test_positive_update_4(self, test_data):
        """
        @feature: Organizations
        @test: Create organization with valid values then update all values
        @assert: organization name, label and description are updated
        """
        org = Organization()
        org = ApiCrud.record_create(org)
        org.name = test_data.name
        org.description = test_data.description

        ApiCrud.record_update(org)
Esempio n. 34
0
    def test_negative_create(self, name):
        """
        @Feature: Environment - Negative Create
        @Test: Create new environment
        @Assert: Environment is created
        """

        environment = Environment(name=name)
        with self.assertRaises(ApiException):
            result = ApiCrud.record_create(environment)
            self.assertIsNone(result)
        self.assertFalse(ApiCrud.record_exists(environment))
Esempio n. 35
0
    def test_cv_create_api(self, data):
        # variations (subject to change):
        # ascii string, alphanumeric, latin-1, utf8, etc.
        """
        @test: create content views (positive)
        @feature: Content Views
        @assert: content views are created
        """

        depends = ApiCrud.record_create_dependencies(data)
        result = ApiCrud.record_create(depends)
        self.assertIntersects(data, result)
Esempio n. 36
0
    def test_negative_create(self, name):
        """
        @Feature: Environment - Negative Create
        @Test: Create new environment
        @Assert: Environment is created
        """

        environment = Environment(name=name)
        with self.assertRaises(ApiException):
            result = ApiCrud.record_create(environment)
            self.assertIsNone(result)
        self.assertFalse(ApiCrud.record_exists(environment))
Esempio n. 37
0
    def test_cv_edit(self, data):
        """
        @test: edit content views - name, description, etc.
        @feature: Content Views
        @assert: edited content view save is successful and info is
        updated
        """

        con_view = ContentViewDefinition()
        depends = ApiCrud.record_create_dependencies(con_view)
        t = ApiCrud.record_create(depends)
        con_view.name = data.name
        ApiCrud.record_update(t)
Esempio n. 38
0
    def test_basic_create(self, test_data):
        """
        @feature: Permissions
        @test: try to create entity first with relevant permissionn
        @assert: entity is created
        """

        entity = test_data()
        deps = ApiCrud.record_create_dependencies(entity)

        user_definition = User()
        user_created = ApiCrud.record_create_recursive(user_definition)

        # user doesn't yet have relevant permission, action should fail
        with self.assertRaises(Exception):
            ApiCrud.record_create(deps, user_definition)

        perm = ApiCrud.record_resolve(test_data._meta.api_class.permissions.create)
        add_permission_to_user(user_created, perm)
        # user should have the relevant permission, action should work
        created = ApiCrud.record_create(deps, user_definition)
        self.assertIntersects(deps, created)
Esempio n. 39
0
 def test_update(self, test_data):
     """
     @feature: ActivationKey
     @test: Verify, that update funkcionality works as intended
     @assert: different description is created after update.
     """
     update_desc = test_data.description
     test_data.description = "empty"
     ak_cr = ApiCrud.record_create(test_data)
     self.assertIntersects(ak_cr, test_data)
     ak_cr.description = update_desc
     ak_u = ApiCrud.record_update(ak_cr)
     self.assertEquals(ak_u.description, ak_cr.description)
Esempio n. 40
0
 def test_update(self, ak):
     """
     @feature: ActivationKey
     @test: Verify, that update funkcionality works as intended
     @assert: different description is created after update.
     """
     update_desc = ak.description
     ak.description = "empty"
     ak_cr = ApiCrud.record_create(ak)
     self.assertIntersects(ak_cr, ak)
     ak_cr.description = update_desc
     ak_u = ApiCrud.record_update(ak_cr)
     self.assertEquals(ak_u.description, ak_cr.description)
Esempio n. 41
0
    def test_basic_create(self, test_data):
        """
        @feature: Permissions
        @test: try to create entity first with relevant permissionn
        @assert: entity is created
        """

        entity = test_data()
        deps = ApiCrud.record_create_dependencies(entity)

        user_definition = User()
        user_created = ApiCrud.record_create_recursive(user_definition)

        # user doesn't yet have relevant permission, action should fail
        with self.assertRaises(Exception):
            ApiCrud.record_create(deps, user_definition)

        perm = ApiCrud.record_resolve(
            test_data._meta.api_class.permissions.create)
        add_permission_to_user(user_created, perm)
        # user should have the relevant permission, action should work
        created = ApiCrud.record_create(deps, user_definition)
        self.assertIntersects(deps, created)
Esempio n. 42
0
    def test_cv_delete(self, data):
        """
        @test: delete content views
        @feature: Content Views
        @assert: edited content view can be deleted and no longer
        appears in any content view UI
        updated
        """

        data.label = "conview_del"
        depends = ApiCrud.record_create_dependencies(data)
        t = ApiCrud.record_create(depends)
        self.assertTrue(ApiCrud.record_exists(t))
        ApiCrud.record_remove(t)
        self.assertFalse(ApiCrud.record_exists(t))
Esempio n. 43
0
    def test_cv_composite_create(self, data):
        # Note: puppet repos cannot/should not be used in this test
        # It shouldn't work - and that is tested in a different case.
        # Individual modules from a puppet repo, however, are a valid
        # variation.
        """
        @test: create a composite content views
        @feature: Content Views
        @setup: sync multiple content source/types (RH, custom, etc.)
        @assert: Composite content views are created
       """

        data.composite = True
        depends = ApiCrud.record_create_dependencies(data)
        result = ApiCrud.record_create(depends)
        self.assertIntersects(data, result)
Esempio n. 44
0
 def test_negative_update_2(self, test_data):
     """
     @feature: Organizations
     @test: Create organization with valid values then fail to update
     its label
     @assert: organization label is not updated
     """
     org = Organization()
     org = ApiCrud.record_create(org)
     org.label = test_data.label
     correctly_failing = True
     try:
         ApiCrud.record_update(org)
         correctly_failing = False
     except ApiException:
         correctly_failing = correctly_failing and True
     self.assertTrue(correctly_failing)
Esempio n. 45
0
 def test_cv_create_api_badorg_negative(self, data):
     # Use an invalid org name
     """
     @test: create content views (negative)
     @feature: Content Views
     @assert: content views are not created; proper error thrown and
     system handles it gracefully
     """
     try:
         data.organization.name = ""
         depends = ApiCrud.record_create_dependencies(data)
         result = ApiCrud.record_create(depends)
         self.assertIntersects(data, result)
         correctly_failing = False
     except ApiException:
         correctly_failing = True
     self.assertTrue(correctly_failing)
Esempio n. 46
0
    def test_cv_create_api_negative_1(self, data):
        # variations (subject to change):
        # zero length, symbols, html, etc.
        """
        @test: create content views (negative)
        @feature: Content Views
        @assert: content views are not created; proper error thrown and
        system handles it gracefully
        """

        try:
            depends = ApiCrud.record_create_dependencies(data)
            result = ApiCrud.record_create(depends)
            self.assertIntersects(data, result)
            correctly_failing = False
        except ApiException:
            correctly_failing = True
        self.assertTrue(correctly_failing)