Browse Source

Added Tempest tests for publicizing a package

Added tests for following scenarios:
    * publicize a non-public package
    * publicize a package as non-admin user (negative test)

Change-Id: I0c2ef75535cdd894ce30d1c1404ce964ec00b248
Wriju Bhattacharya 1 year ago
parent
commit
311f98038d

+ 34
- 0
murano_tempest_tests/tests/api/application_catalog/test_repository.py View File

@@ -178,6 +178,40 @@ class TestRepository(base.BaseApplicationCatalogIsolatedAdminTest):
178 178
     def test_download_package(self):
179 179
         self.application_catalog_client.download_package(self.package['id'])
180 180
 
181
+    @decorators.attr(type='smoke')
182
+    @decorators.idempotent_id('9e55ae34-dea4-4db5-be4a-b3b793c9c4a7')
183
+    def test_publicize_package(self):
184
+        # Given a package that isn't public
185
+        application_name = utils.generate_name('test_publicize_package')
186
+        abs_archive_path, dir_with_archive, archive_name = \
187
+            utils.prepare_package(application_name)
188
+        self.addCleanup(os.remove, abs_archive_path)
189
+        package = self.application_catalog_client.upload_package(
190
+            application_name, archive_name, dir_with_archive,
191
+            {"categories": [], "tags": [], 'is_public': False})
192
+        self.addCleanup(self.application_catalog_client.delete_package,
193
+                        package['id'])
194
+
195
+        fetched_package = self.application_catalog_client.get_package(
196
+            package['id'])
197
+        self.assertFalse(fetched_package['is_public'])
198
+
199
+        # When package is publicized
200
+        post_body = [
201
+            {
202
+                "op": "replace",
203
+                "path": "/is_public",
204
+                "value": True
205
+            }
206
+        ]
207
+        self.application_catalog_client.update_package(package['id'],
208
+                                                       post_body)
209
+
210
+        # Then package becomes public
211
+        fetched_package = self.application_catalog_client.get_package(
212
+            package['id'])
213
+        self.assertTrue(fetched_package['is_public'])
214
+
181 215
     @decorators.idempotent_id('1c017c1b-9efc-4498-95ff-833a9ce565a0')
182 216
     def test_get_ui_definitions(self):
183 217
         self.application_catalog_client.get_ui_definition(self.package['id'])

+ 28
- 0
murano_tempest_tests/tests/api/application_catalog/test_repository_negative.py View File

@@ -163,3 +163,31 @@ class TestRepositoryNegativeForbidden(base.BaseApplicationCatalogTest):
163 163
         self.assertRaises(exceptions.Forbidden,
164 164
                           self.alt_client.get_logo,
165 165
                           self.package['id'])
166
+
167
+    @decorators.attr(type='negative')
168
+    @decorators.idempotent_id('12928ec7-bd31-415d-9260-5c488aebd4c7')
169
+    def test_publicize_package_as_non_admin_user(self):
170
+        # Given a package that isn't public
171
+        application_name = utils.generate_name('test_publicize_package_'
172
+                                               'as_non_admin_user')
173
+        abs_archive_path, dir_with_archive, archive_name = \
174
+            utils.prepare_package(application_name)
175
+        self.addCleanup(os.remove, abs_archive_path)
176
+        package = self.application_catalog_client.upload_package(
177
+            application_name, archive_name, dir_with_archive,
178
+            {"categories": [], "tags": [], 'is_public': False})
179
+        self.addCleanup(self.application_catalog_client.delete_package,
180
+                        package['id'])
181
+
182
+        # When package is publicized, then the method throws an exception
183
+        post_body = [
184
+            {
185
+                "op": "replace",
186
+                "path": "/is_public",
187
+                "value": True
188
+            }
189
+        ]
190
+        self.assertRaises(exceptions.Forbidden,
191
+                          self.application_catalog_client.update_package,
192
+                          package['id'],
193
+                          post_body)

Loading…
Cancel
Save