def test_set_time_frame(self):
        from_date = datetime.date(2012, 9, 18)
        to_date = datetime.date(2015, 1, 8)

        gmor = GetModifiedOrderRequest()
        gmor.set_time_frame(from_date, to_date)

        assert gmor.from_date == "2012-09-18"
        assert gmor.to_date == "2015-01-08"
    def test_set_time_frame(self):
        from_date = datetime.date(2012, 9, 18)
        to_date = datetime.date(2015, 1, 8)

        gmor = GetModifiedOrderRequest()
        gmor.set_time_frame(from_date, to_date)

        assert gmor.from_date == "2012-09-18"
        assert gmor.to_date == "2015-01-08"
    def test_set_credentials(self):
        username = "******"
        password = "******"
        partner_code = "BL2"

        gmor = GetModifiedOrderRequest()
        gmor.set_credentials(partner_code, username, password)

        assert gmor.request_header.username == username
        assert gmor.request_header.password == password
        assert gmor.request_header.partner_code == partner_code
    def test_serialize_get_modified_orders_request(self):

        gmor = GetModifiedOrderRequest()
        gmor.from_date = "2012-09-18"
        gmor.to_date = "2015-01-08"
        root = gmor.serialize()

        assert root.find('.//FromDate').text == "2012-09-18"
        assert root.find('.//ToDate').text == "2015-01-08"
        assert len(root.findall('.//OrderQueryOptions')) == 1
        assert len(root.findall('.//QueryRequestHeader')) == 1
    def test_set_credentials(self):
        username = "******"
        password = "******"
        partner_code = "BL2"

        gmor = GetModifiedOrderRequest()
        gmor.set_credentials(partner_code, username, password)

        assert gmor.request_header.username == username
        assert gmor.request_header.password == password
        assert gmor.request_header.partner_code == partner_code
    def test_serialize_get_modified_orders_request(self):

        gmor = GetModifiedOrderRequest()
        gmor.from_date = "2012-09-18"
        gmor.to_date = "2015-01-08"
        root = gmor.serialize()

        assert root.find('.//FromDate').text == "2012-09-18"
        assert root.find('.//ToDate').text == "2015-01-08"
        assert len(root.findall('.//OrderQueryOptions')) == 1
        assert len(root.findall('.//QueryRequestHeader')) == 1
Example #7
0
    def test_successful_post_request(self, mocked_post):

        endpoint = "http://www.example.com/"
        request_model = GetModifiedOrderRequest()
        credentials = {
            "partner_code": "123456",
            "username": "******",
            "password": "******"
        }
        response = etree.tostring(
            test_utils.create_node_from_file('get_order_by_poid.xml')
        )
        mocked_post.return_value.status_code = 200
        mocked_post.return_value.content = response

        response = post_request(
            endpoint, request_model, credentials
        )

        detail = response.model[0]

        assert detail.organization_contacts.admin.email == (
            "*****@*****.**"
        )
        assert detail.organization_info.city == "City"
        assert detail.organization_info.country == "US"
        assert detail.status_code == "ORDER_COMPLETE"
Example #8
0
 def test_successful_post_request(self):
     pytest.importorskip("treq")
     from treq.testing import (StubTreq, StringStubbingResource,
                               RequestSequence)
     credentials = {
         "partner_code": "123456",
         "username": "******",
         "password": "******"
     }
     errors = []
     from mock import ANY
     sequence_stubs = RequestSequence([
         ((ANY, ANY, ANY, ANY, ANY),
          (200, {},
           etree.tostring(
               test_utils.create_node_from_file('get_order_by_poid.xml'))))
     ], errors.append)
     stub_treq = StubTreq(StringStubbingResource(sequence_stubs))
     with sequence_stubs.consume(errors.append):
         d = post_request_treq(stub_treq,
                               "https://symantec.endpoint.example.com",
                               GetModifiedOrderRequest(), credentials)
         responses = []
         d.addCallback(responses.append)
         d.addErrback(errors.append)
         assert len(responses) == 1
     assert errors == []
    def test_serialize_modified_orders(self):

        re = RequestEnvelope(GetModifiedOrderRequest())

        root = re.serialize()
        mod_requests = root.findall('.//GetModifiedOrders')
        len_mod_request = len(root.find('.//Request'))

        assert len(mod_requests) == 1
        assert len_mod_request > 0
    def test_set_query_options(self):

        gmor = GetModifiedOrderRequest()
        query_options = {
            'product_detail': False,
            'contacts': False,
            'payment_info': False,
            'cert_info': False,
            'fulfillment': False,
            'ca_certs': False,
            'pkcs7_cert': False,
            'partner_tags': False,
            'auth_comments': False,
            'auth_statuses': False,
            'file_auth_dv_summary': False,
            'trust_services_summary': False,
            'trust_services_details': False,
            'vulnerability_scan_summary': False,
            'vulnerability_scan_details': False,
            'cert_algorithm_info': False
        }

        gmor.set_query_options(**query_options)

        assert not gmor.query_options.product_detail
        assert not gmor.query_options.contacts
        assert not gmor.query_options.payment_info
        assert not gmor.query_options.certificate_info
        assert not gmor.query_options.fulfillment
        assert not gmor.query_options.ca_certs
        assert not gmor.query_options.pkcs7_cert
        assert not gmor.query_options.partner_tags
        assert not gmor.query_options.authentication_comments
        assert not gmor.query_options.authentication_statuses
        assert not gmor.query_options.file_auth_dv_summary
        assert not gmor.query_options.trust_services_summary
        assert not gmor.query_options.trust_services_details
        assert not gmor.query_options.vulnerability_scan_summary
        assert not gmor.query_options.vulnerability_scan_details
        assert not gmor.query_options.certificate_algorithm_info
    def test_set_query_options(self):

        gmor = GetModifiedOrderRequest()
        query_options = {
            'product_detail': False,
            'contacts': False,
            'payment_info': False,
            'cert_info': False,
            'fulfillment': False,
            'ca_certs': False,
            'pkcs7_cert': False,
            'partner_tags': False,
            'auth_comments': False,
            'auth_statuses': False,
            'file_auth_dv_summary': False,
            'trust_services_summary': False,
            'trust_services_details': False,
            'vulnerability_scan_summary': False,
            'vulnerability_scan_details': False,
            'cert_algorithm_info': False
        }

        gmor.set_query_options(**query_options)

        assert not gmor.query_options.product_detail
        assert not gmor.query_options.contacts
        assert not gmor.query_options.payment_info
        assert not gmor.query_options.certificate_info
        assert not gmor.query_options.fulfillment
        assert not gmor.query_options.ca_certs
        assert not gmor.query_options.pkcs7_cert
        assert not gmor.query_options.partner_tags
        assert not gmor.query_options.authentication_comments
        assert not gmor.query_options.authentication_statuses
        assert not gmor.query_options.file_auth_dv_summary
        assert not gmor.query_options.trust_services_summary
        assert not gmor.query_options.trust_services_details
        assert not gmor.query_options.vulnerability_scan_summary
        assert not gmor.query_options.vulnerability_scan_details
        assert not gmor.query_options.certificate_algorithm_info
Example #12
0
    def test_bad_response(self, mocked_post):

        endpoint = "http://www.example.com/"
        request_model = GetModifiedOrderRequest()
        credentials = {
            "partner_code": "123456",
            "username": "******",
            "password": "******"
        }

        mocked_post.return_value.status_code = 500
        with pytest.raises(FailedRequest):
            post_request(endpoint, request_model, credentials)