def test_negative_update_same_name(self):
        """Update a bookmark with name already taken

        @Feature: Scoped Search Bookmark Update

        @Setup:

        1. Create 2 bookmarks with a random names with random query

        @Steps:

        1. Try to update the name of the first (or second) Bookmark created in
        the Setup with the name of the second (or first) Bookmark

        @Assert: Error - name already taken, bookmark not updated
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alphanumeric')
                entities.Bookmark(
                    controller=entity['controller'],
                    name=name,
                ).create()
                bm = entities.Bookmark(
                    controller=entity['controller'], ).create()
                bm.name = name
                with self.assertRaises(HTTPError):
                    bm.update(['name'])
                bm = bm.read()
                self.assertNotEqual(bm.name, name)
    def test_negative_create_null_public(self):
        """Create a bookmark omitting the public parameter

        @Feature: Scoped Search Bookmark Create

        @Steps:

        1. Create a new bookmark using a random name, random query and omit the
        'public' parameter
        2. List the bookmarks

        @Assert: Error notification – public is required, Bookmark is not
        created (not listed)

        @BZ: 1302725
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alphanumeric')
                with self.assertRaises(HTTPError):
                    entities.Bookmark(
                        controller=entity['controller'],
                        name=name,
                        public=None,
                    ).create()
                result = entities.Bookmark().search(
                    query={'search': u'name="{0}"'.format(name)})
                self.assertEqual(len(result), 0)
Exemple #3
0
    def test_negative_create_null_public(self):
        """Create a bookmark omitting the public parameter

        :id: 0a4cb5ea-912b-445e-a874-b345e43d3eac

        :Steps:

            1. Create a new bookmark using a random name, random query and omit
               the 'public' parameter
            2. List the bookmarks

        :expectedresults: Error notification - public is required, Bookmark is
            not created (not listed)

        :BZ: 1302725

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alphanumeric')
                with self.assertRaises(HTTPError):
                    entities.Bookmark(controller=entity['controller'],
                                      name=name,
                                      public=None).create()
                result = entities.Bookmark().search(
                    query={'search': 'name="{0}"'.format(name)})
                self.assertEqual(len(result), 0)
    def test_negative_create_empty_query(self):
        """Create a bookmark with empty query

        @Feature: Scoped Search Bookmark Create

        @Steps:

        1. Create a bookmark with providing an empty query
        2. List the bookmarks

        @Assert: Error notification - search query cannot be empty, Bookmark is
        not created (not listed)
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alpha')
                with self.assertRaises(HTTPError):
                    entities.Bookmark(
                        controller=entity['controller'],
                        name=name,
                        query='',
                    ).create()
                result = entities.Bookmark().search(
                    query={'search': u'name="{0}"'.format(name)})
                self.assertEqual(len(result), 0)
Exemple #5
0
def test_negative_create_null_public(controller):
    """Create a bookmark omitting the public parameter

    :id: 0a4cb5ea-912b-445e-a874-b345e43d3eac

    :parametrized: yes

    :Steps:

        1. Attempt to create a bookmark with a random name and valid controller, with public
        attribute set to None.
        2. List the bookmarks.

    :expectedresults:

        1. Error returned.
        2. Bookmark is not listed.

    :BZ: 1302725

    :CaseImportance: Critical
    """
    name = gen_string('alphanumeric')
    with pytest.raises(HTTPError):
        entities.Bookmark(controller=controller, name=name,
                          public=None).create()
    result = entities.Bookmark().search(query={'search': f'name="{name}"'})
    assert len(result) == 0
Exemple #6
0
def test_negative_create_same_name(controller):
    """Create bookmarks with the same names

    :id: f78f6e97-da77-4a61-95c2-622c439d325d

    :parametrized: yes

    :Steps:

        1. Create a bookmark with a random name and valid controller.
        2. Attempt to create a second bookmark, using the same name as the previous bookmark.
        3. List the bookmarks.

    :expectedresults:

        2. Error returned.
        3. Only the first bookmark is listed.

    :CaseImportance: Critical
    """
    name = gen_string('alphanumeric')
    entities.Bookmark(controller=controller, name=name).create()
    with pytest.raises(HTTPError):
        entities.Bookmark(controller=controller, name=name).create()
    result = entities.Bookmark().search(query={'search': f'name="{name}"'})
    assert len(result) == 1
Exemple #7
0
def test_negative_update_same_name(controller):
    """Update a bookmark with name already taken

    :id: 6becf121-2bea-4f7e-98f4-338bd88b8f4b

    :parametrized: yes

    :Steps:

        1. Create a bookmark with a random name and valid controller.
        2. Create a second bookmark for the same controller.
        3. Attempt to update the second bookmark to have the same name as the first bookmark.

    :expectedresults:

        3. Error returned. Second bookmark's name is not updated.

    :CaseImportance: Critical
    """
    name = gen_string('alphanumeric')
    entities.Bookmark(controller=controller, name=name).create()
    bm = entities.Bookmark(controller=controller).create()
    bm.name = name
    with pytest.raises(HTTPError):
        bm.update(['name'])
    bm = bm.read()
    assert bm.name != name
Exemple #8
0
def test_negative_create_with_invalid_name(controller):
    """Create a bookmark with invalid name

    :id: 9a79c561-8225-43fc-8ec7-b6858e9665e2

    :parametrized: yes

    :Steps:

        1. Attempt to create a bookmark with an invalid name.
        2. List the bookmarks.

    :expectedresults:

        1. Error returned.
        2. Bookmark is not listed.

    :CaseImportance: Critical
    """
    name = random.choice(invalid_values_list())
    with pytest.raises(HTTPError):
        entities.Bookmark(controller=controller, name=name,
                          public=False).create()
    result = entities.Bookmark().search(query={'search': f'name="{name}"'})
    assert len(result) == 0
Exemple #9
0
    def test_negative_create_empty_query(self):
        """Create a bookmark with empty query

        :id: 674d569f-6f86-43ba-b9cc-f43e05e8ab1c

        :Steps:

            1. Create a bookmark with providing an empty query
            2. List the bookmarks

        :expectedresults: Error notification - search query cannot be empty,
            Bookmark is not created (not listed)

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alpha')
                with self.assertRaises(HTTPError):
                    entities.Bookmark(controller=entity['controller'],
                                      name=name,
                                      query='').create()
                result = entities.Bookmark().search(
                    query={'search': 'name="{0}"'.format(name)})
                self.assertEqual(len(result), 0)
    def test_negative_create_same_name(self):
        """Create bookmarks with the same names

        @Feature: Scoped Search Bookmark Create

        @Setup:

        1. Create a bookmark with a random name

        @Steps:

        1. Create a new bookmark using a random name
        2. Create a second bookmark, using the same name as
        the previous Bookmark. Assert that an error is raised.
        3. List the bookmarks. Assert that the Bookmark created is present and
        there's only one listed

        @Assert: Error notification - name already taken, Bookmark is not
        created (not listed)
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alphanumeric')
                entities.Bookmark(
                    controller=entity['controller'],
                    name=name,
                ).create()
                with self.assertRaises(HTTPError):
                    entities.Bookmark(
                        controller=entity['controller'],
                        name=name,
                    ).create()
                result = entities.Bookmark().search(
                    query={'search': u'name="{0}"'.format(name)})
                self.assertEqual(len(result), 1)
Exemple #11
0
    def test_negative_create_same_name(self):
        """Create bookmarks with the same names

        :id: f78f6e97-da77-4a61-95c2-622c439d325d

        :Setup: Create a bookmark with a random name

        :Steps:

            1. Create a new bookmark using a random name
            2. Create a second bookmark, using the same name as the previous
               Bookmark. Assert that an error is raised.
            3. List the bookmarks. Assert that the Bookmark created is present
               and there's only one listed

        :expectedresults: Error notification - name already taken, Bookmark is
            not created (not listed)

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alphanumeric')
                entities.Bookmark(controller=entity['controller'],
                                  name=name).create()
                with self.assertRaises(HTTPError):
                    entities.Bookmark(controller=entity['controller'],
                                      name=name).create()
                result = entities.Bookmark().search(
                    query={'search': 'name="{0}"'.format(name)})
                self.assertEqual(len(result), 1)
Exemple #12
0
    def test_negative_create_with_invalid_name(self):
        """Create a bookmark with invalid name

        :id: 9a79c561-8225-43fc-8ec7-b6858e9665e2

        :Steps:

            1. Attempt to create a bookmark with providing an invalid name
            2. List the bookmarks

        :expectedresults: Error returned, Bookmark is not created (not listed)

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                for name in invalid_values_list():
                    with self.subTest(name):
                        with self.assertRaises(HTTPError):
                            entities.Bookmark(controller=entity['controller'],
                                              name=name,
                                              public=False).create()
                        result = entities.Bookmark().search(
                            query={'search': 'name="{0}"'.format(name)})
                        self.assertEqual(len(result), 0)
Exemple #13
0
    def test_negative_update_same_name(self):
        """Update a bookmark with name already taken

        :id: 6becf121-2bea-4f7e-98f4-338bd88b8f4b

        :Setup: Create 2 bookmarks with a random names with random query

        :Steps: Try to update the name of the first (or second) Bookmark
            created in the Setup with the name of the second (or first)
            Bookmark

        :expectedresults: Error - name already taken, bookmark not updated

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                name = gen_string('alphanumeric')
                entities.Bookmark(controller=entity['controller'],
                                  name=name).create()
                bm = entities.Bookmark(
                    controller=entity['controller']).create()
                bm.name = name
                with self.assertRaises(HTTPError):
                    bm.update(['name'])
                bm = bm.read()
                self.assertNotEqual(bm.name, name)
Exemple #14
0
    def test_positive_update_public(self):
        """Update a bookmark public state to private and vice versa

        :id: 2717360d-37c4-4bb9-bce1-b1edabdf11b3

        :Setup: Create a bookmark with a random name and random query with
            public attribute set to True/False

        :Steps:

            1. Update the bookmarks 'public' attribute
            2. List the bookmarks

        :expectedresults: Bookmark is updated with new public state

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                for public in (True, False):
                    with self.subTest(public):
                        bm = entities.Bookmark(controller=entity['controller'],
                                               public=not public).create()
                        self.assertNotEqual(bm.public, public)
                        bm.public = public
                        bm = bm.update(['public'])
                        self.assertEqual(bm.public, public)
Exemple #15
0
def test_negative_delete_bookmark(random_entity, module_viewer_user,
                                  test_name):
    """Simple removal of a bookmark query without permissions

    :id: 1a94bf2b-bcc6-4663-b70d-e13244a0783b

    :Setup:

        1. Create a bookmark of a random name with random query
        2. Create a non-admin user without destroy_bookmark role (e.g.
           viewer)

    :Steps:

        1. Login to Satellite server (establish a UI session) as a
           non-admin user
        2. List the bookmarks (Navigate to Administer -> Bookmarks)

    :expectedresults: The delete buttons are not displayed

    :CaseLevel: Integration
    """
    bookmark = entities.Bookmark(
        controller=random_entity['controller'],
        public=True,
    ).create()
    with Session(test_name, module_viewer_user.login,
                 module_viewer_user.password) as non_admin_session:
        assert non_admin_session.bookmark.search(
            bookmark.name)[0]['Name'] == bookmark.name
        with raises(NoSuchElementException):
            non_admin_session.bookmark.delete(bookmark.name)
        assert non_admin_session.bookmark.search(
            bookmark.name)[0]['Name'] == bookmark.name
Exemple #16
0
    def test_pre_create_public_enable_bookmark(self, request):
        """Create public enable bookmark for system entities using available bookmark
        data.

        :id: preupgrade-c4f90034-ea57-4a4d-9b73-0f57f824d89e

        :Steps:

            1. Create public enable bookmarks before the upgrade for all system entities
            using available bookmark data.
            2. Check the bookmark attribute(controller, name, query public) status
            for all the system entities.

        :expectedresults: Public enabled bookmark should be created successfully.

        :BZ: 1833264, 1826734, 1862119

        :CaseImportance: Critical
        """

        for entity in BOOKMARK_ENTITIES:
            book_mark_name = entity["name"] + request.node.name
            bm = entities.Bookmark(
                controller=entity['controller'],
                name=book_mark_name,
                public=True,
                query=f"name={book_mark_name}",
            ).create()
            assert bm.controller == entity['controller']
            assert bm.name == book_mark_name
            assert bm.query == f"name={book_mark_name}"
            assert bm.public
Exemple #17
0
    def test_post_create_public_disable_bookmark(self,
                                                 dependent_scenario_name):
        """Check the status of public disabled bookmark for all the
        system entities(activation keys, tasks, compute profile, content hosts etc) after upgrade.

        :id: postupgrade-3b3abb85-cad2-4cbb-ad21-2780523351fd

        :Steps:

            1. Check the bookmark status after post-upgrade.
            2. Remove the bookmark.

        :expectedresults: Public disabled bookmarks details for all the system entities
        should be unchanged after upgrade.

        :CaseImportance: Critical
        """
        pre_test_name = dependent_scenario_name
        for entity in BOOKMARK_ENTITIES:
            book_mark_name = entity["name"] + pre_test_name
            bm = entities.Bookmark().search(
                query={'search': f'name="{book_mark_name}"'})[0]
            assert bm.controller == entity['controller']
            assert bm.name == book_mark_name
            assert bm.query == f"name={book_mark_name}"
            assert not bm.public

            bm.delete()
Exemple #18
0
def test_negative_create_with_duplicate_name(session, random_entity):
    """Create bookmark with duplicate name

    :id: 18168c9c-bdd1-4839-a506-cf9b06c4ab44

    :Setup:

        1. Create a bookmark of a random name with random query.

    :Steps:

        1. Create new bookmark with duplicate name.

    :expectedresults: Bookmark can't be created, submit button is disabled

    :BZ: 1920566, 1992652

    :CaseLevel: Integration
    """
    query = gen_string('alphanumeric')
    bookmark = entities.Bookmark(controller=random_entity['controller'],
                                 public=True).create()
    with session:
        assert session.bookmark.search(
            bookmark.name)[0]['Name'] == bookmark.name
        ui_lib = getattr(session, random_entity['name'].lower())
        with pytest.raises(DisabledWidgetError) as error:
            ui_lib.create_bookmark({
                'name': bookmark.name,
                'query': query,
                'public': True
            })
            assert error == 'name already exists'
        assert len(session.bookmark.search(bookmark.name)) == 1
Exemple #19
0
    def test_positive_create_with_query(self):
        """Create a bookmark

        :id: 9fb6d485-92b5-43ea-b776-012c13734100

        :Steps:

            1. Create a bookmark with a random query, name and random valid
               controller
            2. List the bookmarks

        :expectedresults: No errors, Bookmark is listed, controller matches the
            controller the bookmark was created for

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                for query in valid_data_list():
                    with self.subTest(query):
                        bm = entities.Bookmark(
                            controller=entity['controller'],
                            query=query,
                        ).create()
                        self.assertEqual(bm.controller, entity['controller'])
                        self.assertEqual(bm.query, query)
Exemple #20
0
    def test_positive_create_public(self):
        """Create a public bookmark

        :id: 511b9bcf-0661-4e44-b1bc-475a1c207aa9

        :Steps:

            1. Create a bookmark with a random name and public = true
            2. List the bookmarks

        :expectedresults: No errors, Bookmark is listed, controller matches the
            entity the bookmark was created for and is displayed as public

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                for public in (True, False):
                    with self.subTest(public):
                        bm = entities.Bookmark(
                            controller=entity['controller'],
                            public=public,
                        ).create()
                        self.assertEqual(bm.controller, entity['controller'])
                        self.assertEqual(bm.public, public)
    def test_positive_update_public(self):
        """Update a bookmark public state to private and vice versa

        @Feature: Scoped Search Bookmark Update

        @Setup:

        1. Create a bookmark with a random name and random query with public
        attribute set to True/False

        @Steps:

        1. Update the bookmarks 'public' attribute
        2. List the bookmarks

        @Assert: Bookmark is updated with new public state
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                for public in (True, False):
                    with self.subTest(public):
                        bm = entities.Bookmark(
                            controller=entity['controller'],
                            public=not public,
                        ).create()
                        self.assertNotEqual(bm.public, public)
                        bm.public = public
                        bm = bm.update(['public'])
                        self.assertEqual(bm.public, public)
Exemple #22
0
    def test_negative_delete_bookmark(self):
        """Simple removal of a bookmark query without permissions

        :id: 1a94bf2b-bcc6-4663-b70d-e13244a0783b

        :Setup:

            1. Create a bookmark of a random name with random query
            2. Create a non-admin user without destroy_bookmark role (e.g.
               viewer)

        :Steps:

            1. Login to Satellite server (establish a UI session) as a
               non-admin user
            2. List the bookmarks (Navigate to Administer -> Bookmarks)

        :expectedresults: The delete buttons are not displayed

        :CaseLevel: Integration
        """
        bm = entities.Bookmark(
            controller=self.getOneEntity()[0]['controller'],
            public=True,
        ).create()
        with Session(self.browser, user=self.custom_user.login,
                     password=self.custom_password):
            with self.assertRaises(UIError):
                self.bookmark.delete(bm.name)
Exemple #23
0
def test_post_create_public_disable_bookmark(request):
    """Check the status of public disable bookmark for all the
    system entities(activation keys, tasks, compute profile, content hosts etc) after upgrade

    :id: 3b3abb85-cad2-4cbb-ad21-2780523351fd

    :Steps:

        1. Check the bookmark status after post-upgrade
        2. Remove the bookmark

    :expectedresults: Public disabled bookmarks details for all the system entities
    should be unchanged after upgrade

    :CaseImportance: Critical
    """
    pre_test_name = [
        mark.kwargs['depend_on'].__name__
        for mark in request.node.own_markers
        if 'depend_on' in mark.kwargs
    ][0]
    for entity in BOOKMARK_ENTITIES:
        book_mark_name = entity["name"] + pre_test_name
        bm = entities.Bookmark().search(query={'search': f'name="{book_mark_name}"'})[0]
        assert bm.controller == entity['controller']
        assert bm.name == book_mark_name
        assert bm.query == f"name={book_mark_name}"
        assert not bm.public
        bm.delete()
Exemple #24
0
def test_negative_update_invalid_name(controller):
    """Update a bookmark with an invalid name

    :id: 479795bb-aeed-45b3-a7e3-d3449c808087

    :parametrized: yes

    :Steps:

        1. Create a bookmark with valid controller.
        2. Attempt to update the bookmark with an invalid name.

    :expectedresults:

        2. Error returned. Bookmark name is not updated.

    :CaseImportance: Critical
    """
    new_name = random.choice(invalid_values_list())
    bm = entities.Bookmark(controller=controller, public=False).create()
    bm.name = new_name
    with pytest.raises(HTTPError):
        bm.update(['name'])
    bm = bm.read()
    assert bm.name != new_name
    def test_positive_update_name(self):
        """Update a bookmark

        @id: 1cde270a-26fb-4cff-bdff-89fef17a7624

        @Setup:

        1. Create a new bookmark with a random name and random query

        @Steps:

        1. Update the previously created bookmark with another random name

        @Assert: The new bookmark name is listed
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                bm = entities.Bookmark(
                    controller=entity['controller'],
                    public=False,
                ).create()
                for new_name in valid_data_list():
                    with self.subTest(new_name):
                        bm.name = new_name
                        bm = bm.update(['name'])
                        self.assertEqual(bm.name, new_name)
    def test_negative_update_invalid_name(self):
        """Update a bookmark with an invalid name

        @Feature: Scoped Search Bookmark Update

        @Setup:

        1. Create a bookmark with a random name and random query

        @Steps:

        1. Update the name of the previously created bookmarks to an invalid
        value

        @Assert: Error - bookmark not updated
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                bm = entities.Bookmark(
                    controller=entity['controller'], ).create()
                for new_name in invalid_values_list():
                    with self.subTest(new_name):
                        bm.name = new_name
                        with self.assertRaises(HTTPError):
                            bm.update(['name'])
                        bm = bm.read()
                        self.assertNotEqual(bm.name, new_name)
Exemple #27
0
    def test_negative_update_invalid_name(self):
        """Update a bookmark with an invalid name

        :id: 479795bb-aeed-45b3-a7e3-d3449c808087

        :Setup: Create a bookmark with a random name and random query

        :Steps: Update the name of the previously created bookmarks to an
            invalid value

        :expectedresults: Error - bookmark not updated

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                bm = entities.Bookmark(controller=entity['controller'],
                                       public=False).create()
                for new_name in invalid_values_list():
                    with self.subTest(new_name):
                        bm.name = new_name
                        with self.assertRaises(HTTPError):
                            bm.update(['name'])
                        bm = bm.read()
                        self.assertNotEqual(bm.name, new_name)
    def test_positive_update_query(self):
        """Update a bookmark query

        @id: 92a31de2-bebf-4396-94f5-adf59f8d66a5

        @Setup:

        1. Create a bookmark with a random name and random query

        @Steps:

        1. Update the query of the previously created bookmark

        @Assert: The updated query submitted
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                bm = entities.Bookmark(
                    controller=entity['controller'],
                ).create()
                for new_query in valid_data_list():
                    with self.subTest(new_query):
                        bm.query = new_query
                        bm = bm.update(['query'])
                        self.assertEqual(bm.query, new_query)
Exemple #29
0
    def test_positive_create_with_name(self):
        """Create a bookmark

        :id: aeef0944-379a-4a27-902d-aa5969dbd441

        :Steps:

            1. Create a bookmark with a random name, query and random valid
               controller
            2. List the bookmarks

        :expectedresults: No errors, Bookmark is listed, controller matches the
            controller the bookmark was created for

        :CaseImportance: Critical
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                for name in valid_data_list().values():
                    with self.subTest(name):
                        bm = entities.Bookmark(controller=entity['controller'],
                                               name=name,
                                               public=False).create()
                        self.assertEqual(bm.controller, entity['controller'])
                        self.assertEqual(bm.name, name)
    def test_negative_update_empty_query(self):
        """Update a bookmark with an empty query

        @id: 948602d3-532a-47fe-b313-91e3fab809bf

        @Setup:

        1. Create a bookmark with a random name and random query

        @Steps:

        1. Update the query of the pre-created bookmark with an empty value

        @Assert: Error - search query cannot be empty, bookmark not updated
        """
        for entity in BOOKMARK_ENTITIES:
            with self.subTest(entity['controller']):
                bm = entities.Bookmark(
                    controller=entity['controller'],
                ).create()
                bm.query = ''
                with self.assertRaises(HTTPError):
                    bm.update(['query'])
                bm = bm.read()
                self.assertNotEqual(bm.query, '')