#!/usr/share/ucs-test/runner python ## desc: Check if an app's page in the appcenter can be opened via url. ## roles: [domaincontroller_master] ## tags: [basic, apptest] ## bugs: [38544, 39236] ## packages: [univention-management-console-module-appcenter] ## exposure: careful from httplib import HTTPException import json import univention.testing.utils as utils from univention.testing.umc import UMCTestConnection REQUEST_METHOD = 'POST' APPCENTER_URL = 'https://localhost/univention-management-console/command/appcenter/get' APP_NAME = 'univention-demo' # redirected from https://localhost/univention-management-console/?module=appcenter&flavor=appcenter&app=APP_NAME fail_messages = [] try: connection = UMCTestConnection('localhost') umc_connection = connection.get_connection() options = json.dumps({'options': {'application': APP_NAME}}) headers = connection._headers umc_connection.request(REQUEST_METHOD, APPCENTER_URL, options, headers) umc_response = umc_connection.getresponse() status = umc_response.status response = json.loads(umc_response.read()) except HTTPException as e: utils.fail("Exception while making request '%s':\n%s: %s" % (APPCENTER_URL, type(e), e)) if status != 200: fail_messages += ["The server returned status code %d." % status] try: if response['result']['id'] != APP_NAME: raise AssertionError("response['result']['id'] != APP_NAME") except (KeyError, AssertionError) as e: fail_messages += ["The server did not return the page of the requested app '%s':\n%s: %s" % (APP_NAME, type(e), e)] if fail_messages: utils.fail('\n'.join(fail_messages))