示例#1
0
    def test_user(self):
        print_caption("User Resources")

        # GET user list
        response = test_method(self, 'get', resource_url('user'))

        # GET user detail
        response = test_details(self, 'get', response, 'user_list', mandatory_fields=['timezone'])

        # GET user/contact_channel detail
        if response:
            data = data_from_response(response)
            if data['contact_info']:
                test_method(self, 'get', data['contact_info'][0]['url'][len("%s" % (URL_BASE)):])

        # PUT user detail
        if response:
            data = data_from_response(response, ['created', 'contact_info'])
            test_details(self, 'put', response, None, True, data)

        # POST user
        if response:
            data = data_from_response(response, ['created', 'contact_info'])
            data['username'] = data['username'] * 2
            post_response = test_method(self, 'post', resource_url('user'), data)

        # DELETE user detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))
示例#2
0
    def test_rotating_contact(self):
        print_caption("Rotating Contact Resources")

        # GET rotating_contact list
        response = test_method(self, 'get', resource_url('rotating_contact'))

        # GET rotating_contact detail
        response = test_details(self, 'get', response, 'rotating_contact_list')

        # GET active rotating_contact list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='active')

        # PUT rotating_contact detail
        if response:
            data = data_from_response(response)
            test_details(self, 'put', response, None, True, data)

        # POST rotating_contact
        if response:
            data = data_from_response(response)
            post_response = test_method(self, 'post', resource_url('rotating_contact'), data)

        # DELETE rotating_contact detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))
示例#3
0
    def test_contact(self):
        print_caption("Contact Resources")

        # GET contact list
        response = test_method(self, 'get', resource_url('contact'))

        # GET contact detail
        response = test_details(self, 'get', response, 'contact_list')

        # GET contact/contact_channel detail
        if response:
            data = data_from_response(response)
            if data['contact_info']:
                test_method(self, 'get', data['contact_info'][0]['url'][len("%s" % (URL_BASE)):])

        # PUT contact detail
        if response:
            data = data_from_response(response, ['contact_info'])
            test_details(self, 'put', response, None, True, data)

        # POST contact
        if response:
            data = data_from_response(response, ['contact_info'])
            post_response = test_method(self, 'post', resource_url('contact'), data)

        # DELETE contact detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))
示例#4
0
    def test_outage(self):
        print_caption("Outage Resources")

        # GET active outage list
        test_method(self, 'get', resource_url('outage/active'))

        # GET outage list
        response = test_method(self, 'get', resource_url('outage'))

        # GET outage detail
        response = test_details(self, 'get', response, 'outage_list')

        # GET outage log list
        if response: 
            log_response = test_details(self, 'get', response, None, True, nested_uri='outage_log')
            if log_response:
                data = data_from_response(log_response, ['timestamp', 'user_name'], list_root='outage_log_list', mandatory_fields=['user'])
                test_details(self, 'post', response, None, True, data, nested_uri='outage_log')
        
        # Public alike methods
        if response:
            delay = 300
            data = {
                'who': api_server.UserResource().get_url(masterdb.User.select()[0].id)        
            }

            # PUT acknowledge outage
            test_details(self, 'put', response, None, True, data, nested_uri='acknowledge')

            # PUT delay outage
            test_details(self, 'put', response, None, True, data, nested_uri='delay/%s' % delay)

            # PUT escalate outage
            test_details(self, 'put', response, None, True, data, nested_uri='escalate')
示例#5
0
    def test_meta(self):
        print_caption("META Resources")

        # GET monitoring_node list
        response = test_method(self, 'get', resource_url('monitoring_node'))

        # GET monitoring_node detail
        response = test_details(self, 'get', response, 'monitoring_node_list')


        # GET agent_resource_type list
        response = test_method(self, 'get', resource_url('agent_resource_type'))

        # GET agent_resource_type detail
        response = test_details(self, 'get', response, 'agent_resource_type_list')


        # GET network_service_type list
        response = test_method(self, 'get', resource_url('network_service_type'))

        # GET network_service_type detail
        response = test_details(self, 'get', response, 'network_service_type_list', mandatory_fields=['options'])

        # GET network_service_type option detail
        if response: 
            response = test_details(self, 'get', response, 'options')


        # GET contact_type list
        response = test_method(self, 'get', resource_url('contact_type'))

        # GET contact_type detail
        response = test_details(self, 'get', response, 'contact_type_list')
示例#6
0
    def test_swagger_doc(self):
        print_caption("Swagger Document")

        # GET schema resource list
        response = test_method(self, 'get', resource_url('schema/resources'))

        # GET customer detail
        data = data_from_response(response)
        for api in data['apis']:
            test_method(self, 'get', resource_url(api['path'].strip("/")))
示例#7
0
    def test_timezone(self):
        print_caption("Timezone Resources")

        # GET timezone list
        response = test_method(self, 'get', resource_url('timezone'))

        # GET timezone detail
        response = test_details(self, 'get', response, 'timezone_list')
示例#8
0
    def test_maintenance_schedule(self):
        print_caption("Maintenance Schedule Resources")

        # GET active maintenance_schedule list
        test_method(self, 'get', resource_url('maintenance_schedule/active'))

        # GET maintenance_schedule list
        response = test_method(self, 'get', resource_url('maintenance_schedule'))

        # GET maintenance_schedule detail
        response = test_details(self, 'get', response, 'maintenance_schedule_list', mandatory_fields=['targets'])

        # PUT maintenance_schedule detail
        if response:
            data = data_from_response(response, ['next_start_time', 'original_start_time'])
            test_details(self, 'put', response, None, True, data)

        # POST maintenance_schedule
        if response:
            data = data_from_response(response, ['next_start_time', 'original_start_time'])
            post_response = test_method(self, 'post', resource_url('maintenance_schedule'), data)

        # DELETE maintenance_schedule detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))


        if response:
            num_minutes = 5

            # PUT pause schedule
            test_details(self, 'put', response, None, True, nested_uri='pause')

            # PUT resume schedule
            test_details(self, 'put', response, None, True, nested_uri='resume')

            # PUT extend schedule
            test_details(self, 'put', response, None, True, nested_uri='extend/%s' % num_minutes)

            # PUT resume schedule
            test_details(self, 'put', response, None, True, nested_uri='terminate')
示例#9
0
    def test_public(self):
        print_caption("Public Resources")

        hash = masterdb.EmailAlert.select()[0].hash
        delay = 300
        data = {
            'who': api_server.UserResource().get_url(masterdb.User.select()[0].id)        
        }

        # GET acknowledge outage
        test_method(self, 'get', resource_url('public/outage/%s/acknowledge' % hash), data)

        # GET delay outage
        test_method(self, 'get', resource_url('public/outage/%s/delay/%s' % (hash, delay)), data)

        # GET escalate outage
        test_method(self, 'get', resource_url('public/outage/%s/escalate' % hash), data)

        # PUT acknowledge outage
        test_method(self, 'put', resource_url('public/outage/%s/acknowledge' % hash), data)

        # PUT delay outage
        test_method(self, 'put', resource_url('public/outage/%s/delay/%s' % (hash, delay)), data)

        # PUT escalate outage
        test_method(self, 'put', resource_url('public/outage/%s/escalate' % hash), data)
示例#10
0
    def test_customer(self):
        print_caption("Customer Resources")

        # GET customer list
        response = test_method(self, 'get', resource_url('customer'))

        # GET customer detail
        response = test_details(self, 'get', response, 'customer_list', mandatory_fields=["brand"])

        # PUT customer detail
        if response:
            data = data_from_response(response, ['customer_key'])
            test_details(self, 'put', response, None, True, data)

        # POST customer
        if response:
            data = data_from_response(response, ['customer_key', 'status'])
            post_response = test_method(self, 'post', resource_url('customer'), data)

        # DELETE customer detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))
示例#11
0
    def test_notification_schedule(self):
        print_caption("Notification Schedule Resources")

        # GET notification_schedule list
        response = test_method(self, 'get', resource_url('notification_schedule'))

        # GET notification_schedule detail
        response = test_details(self, 'get', response, 'notification_schedule_list', mandatory_fields=['targets', 'actions'])

        # POST notification_schedule
        if response:
            data = data_from_response(response)
            post_response = test_method(self, 'post', resource_url('notification_schedule'), data)

        # DELETE notification_schedule detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))

        # PUT notification_schedule detail
        if response:
            data = data_from_response(response)
            test_details(self, 'put', response, None, True, data)
示例#12
0
    def test_email_report(self):
        print_caption("Email Report Resources")

        # GET email_report list
        response = test_method(self, 'get', resource_url('email_report'))

        # GET email_report detail
        response = test_details(self, 'get', response, 'email_report_list')

        # PUT email_report detail
        if response:
            data = data_from_response(response, ['next_send_time'])
            test_details(self, 'put', response, None, True, data)

        # POST email_report
        if response:
            data = data_from_response(response, ['next_send_time'])
            post_response = test_method(self, 'post', resource_url('email_report'), data)

        # DELETE email_report detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))
示例#13
0
    def test_contact_group(self):
        print_caption("Contact Group Resources")

        # GET contact_group list
        response = test_method(self, 'get', resource_url('contact_group'))

        # GET contact_group detail
        response = test_details(self, 'get', response, 'contact_group_list')

        # PUT contact_group detail
        if response:
            data = data_from_response(response)
            test_details(self, 'put', response, None, True, data)

        # POST contact_group
        if response:
            data = data_from_response(response)
            post_response = test_method(self, 'post', resource_url('contact_group'), data)

        # DELETE contact_group detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))
示例#14
0
    def test_compound_service(self):
        print_caption("Compound Service Resources")

        # GET compound_service list
        response = test_method(self, 'get', resource_url('compound_service'))

        # GET compound_service detail
        response = test_details(self, 'get', response, 'compound_service_group_list', mandatory_fields=['notification_schedule', 'network_services'])

        # PUT compound_service detail
        if response:
            data = data_from_response(response, ['created'])
            test_details(self, 'put', response, None, True, data)

        # POST compound_service
        if response:
            data = data_from_response(response, ['status', 'created'])
            post_response = test_method(self, 'post', resource_url('compound_service'), data)

        # DELETE compound_service detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))
示例#15
0
    def test_server_group(self):
        print_caption("Server Group Resources")

        # GET server_group list
        response = test_method(self, 'get', resource_url('server_group'))

        # GET server_group detail-
        response = test_details(self, 'get', response, 'server_group_list', mandatory_fields=['notification_schedule'])

        # PUT server_group detail
        if response:
            data = data_from_response(response)
            test_details(self, 'put', response, None, True, data)

        # POST server_group
        if response:
            data = data_from_response(response)
            post_response = test_method(self, 'post', resource_url('server_group'), data)

        # DELETE server_group detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))


        # GET server_group server list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='server')


        # GET server_group compound_service list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='compound_service')


        # GET server_group server_group list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='server_group')
示例#16
0
    def test_server(self):
        print_caption("Server Resources")

        # GET server list
        response = test_method(self, 'get', resource_url('server'))

        # GET server detail
        response = test_details(self, 'get', response, 'server_list', mandatory_fields=['notification_schedule', 'primary_monitoring'])

        # PUT server detail
        if response:
            data = data_from_response(response, ['additional_fqdns', 'agent_installed', 'agent_version', 'created'])
            test_details(self, 'put', response, None, True, data)

        # POST server
        if response:
            data = data_from_response(response, ['additional_fqdns', 'agent_installed', 'agent_version', 'created', 'server_key', 'status'])
            post_response = test_method(self, 'post', resource_url('server'), data)

        # DELETE server detail
        if response:
            test_method(self, 'delete', get_new_object_location(post_response))


        # GET server availability
        if response: 
            time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            data = {
                'start_time': time,
                'end_time': time            
            }
            test_details(self, 'get', response, None, True, data, nested_uri='availability')


        # GET server child_server list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='child_server')


        # GET server child_compound_service list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='child_compound_service')


        # GET server network_service list
        network_service_response = None
        if response: 
            network_service_response = test_details(self, 'get', response, None, True, nested_uri='network_service')

        # GET server network_service detail
        if network_service_response: 
            network_service_response = test_details(self, 'get', network_service_response, 'network_service_list', mandatory_fields=['metadata'])

        # PUT server network_service detail
        if network_service_response:
            data = data_from_response(network_service_response, ['monitor_node'])
            test_details(self, 'put', network_service_response, None, True, data)

        # POST server network_service
        if network_service_response:
            data = data_from_response(network_service_response, ['monitor_node'])
            post_response = test_details(self, 'post', response, None, True, data, nested_uri='network_service')

        # DELETE server network_service
        if network_service_response:
            test_method(self, 'delete', get_new_object_location(post_response))


        # GET server agent_resource list
        agent_resource_response = None
        if response: 
            agent_resource_response = test_details(self, 'get', response, None, True, nested_uri='agent_resource')

        # GET server agent_resource detail
        if agent_resource_response: 
            agent_resource_response = test_details(self, 'get', agent_resource_response, 'agent_resource_list')

        # PUT server agent_resource detail
        if agent_resource_response:
            data = data_from_response(agent_resource_response, ['agent_resource_type'])
            test_details(self, 'put', agent_resource_response, None, True, data)

        # POST server agent_resource
        if agent_resource_response:
            data = data_from_response(agent_resource_response, ['agent_resource_type'])
            post_response = test_details(self, 'post', response, None, True, data, nested_uri='agent_resource')

        # DELETE server agent_resource detail
        if agent_resource_response:
            test_method(self, 'delete', get_new_object_location(post_response))


        # GET server snmp_resource list
        snmp_resource_response = None
        if response: 
            snmp_resource_response = test_details(self, 'get', response, None, True, nested_uri='snmp_resource')

        # GET server snmp_resource detail
        if snmp_resource_response: 
            snmp_resource_response = test_details(self, 'get', snmp_resource_response, 'snmp_resource_list')

        # PUT server snmp_resource detail
        if snmp_resource_response:
            data = data_from_response(snmp_resource_response, ['snmp_resource_type'])
            test_details(self, 'put', snmp_resource_response, None, True, data)

        # POST server snmp_resource
        if snmp_resource_response:
            data = data_from_response(snmp_resource_response, ['snmp_resource_type'])
            post_response = test_details(self, 'post', response, None, True, data, nested_uri='snmp_resource')

        # DELETE server snmp_resource detail
        if snmp_resource_response:
            test_method(self, 'delete', get_new_object_location(post_response))


        # GET server maintenance_schedule list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='maintenance_schedule')


        # GET server outage list
        if response: 
            test_details(self, 'get', response, None, True, nested_uri='outage')