Esempio n. 1
0
def _ca_modify_order(self, order_meta, plugin_meta):
    """Sends a request to the Symantec CA to modify an order.

    Parameters needed for modifyOrder:
        PartnerOrderID - Needed to specify order
        PartnerCode - Needed to specify order
        ProductCode - Needed to specify order

    Also need a dict, order_meta with the parameters/values to modify.

    returns: tuple with success, error message, and can retry.
    """
    api = Symantec(self.username, self.password, self.url)

    order_details = {
        "PartnerOrderID": plugin_meta["PartnerOrderID"],
        "PartnerCode": plugin_meta["PartnerCode"],
        "ProductCode": plugin_meta["ProductCode"],
    }

    order_details.update(order_meta)

    try:
        api.validate_order_parameters(**order_details)
        return True, None, False
    except symantec_exceptions.SymantecError as e:
        return False, e, False
    except request_exceptions.RequestException as e:
        return False, e, True
Esempio n. 2
0
def _ca_cancel_order(self, plugin_meta):
    """Sends a request to the Symantec CA to cancel an order.

    Parameters needed for modifyOrder:
        PartnerOrderID - Needed to specify order
        PartnerCode - Needed to specify order
        ProductCode - Needed to specify order

    returns: tuple with success, error message, and can retry.
    """
    api = Symantec(self.username, self.password, self.url)

    order_details = {
        "PartnerOrderID": plugin_meta["PartnerOrderID"],
        "PartnerCode": plugin_meta["PartnerCode"],
        "ProductCode": plugin_meta["ProductCode"],
        "ModifyOrderOperation": "CANCEL",
    }

    try:
        api.modify_order(**order_details)
        return True, None, False
    except symantec_exceptions.SymantecError as e:
        return False, e, False
    except request_exceptions.RequestException as e:
        return False, e, True
Esempio n. 3
0
def _ca_cancel_order(self, plugin_meta):
    """Sends a request to the Symantec CA to cancel an order.

    Parameters needed for modifyOrder:
        PartnerOrderID - Needed to specify order
        PartnerCode - Needed to specify order
        ProductCode - Needed to specify order

    returns: tuple with success, error message, and can retry.
    """
    api = Symantec(self.username, self.password, self.url)

    order_details = {
        "PartnerOrderID": plugin_meta["PartnerOrderID"],
        "PartnerCode": plugin_meta["PartnerCode"],
        "ProductCode": plugin_meta["ProductCode"],
        "ModifyOrderOperation": "CANCEL",
    }

    try:
        api.modify_order(**order_details)
        return True, None, False
    except symantec_exceptions.SymantecError as e:
        return False, e, False
    except request_exceptions.RequestException as e:
        return False, e, True
Esempio n. 4
0
def _ca_get_order_status(self, plugin_meta):
    """Sends a request to the Symantec CA for details on an order.

    Parameters needed for GetOrderByPartnerOrderID:
    plugin_meta parameters: PartnerOrderId, PartnerCode

    If the order is complete, the Certificate is returned as a string.
    returns: tuple with success, error message, can retry,
             and the certificate (if available).
    """
    api = Symantec(self.username, self.password, self.url)

    order_details = {
        "PartnerOrderID": plugin_meta["PartnerOrderID"],
        "PartnerCode": plugin_meta["PartnerCode"],
        "ReturnCertificateInfo": "TRUE",
        "ReturnFulfillment": "TRUE",
        "ReturnCaCerts": "TRUE",
    }

    try:
        order_data = api.get_order_by_partner_order_id(**order_details)
        if order_data["OrderInfo"]["OrderState"] == "COMPLETED":
            ca = order_data["Fulfillment"]["CACertificates"]["CACertificate"]
            return True, None, False, ca["CACert"]
        return True, None, False, None
    except symantec_exceptions.SymantecError as e:
        return False, e, False, None
    except request_exceptions.RequestException as e:
        return False, e, True, None
Esempio n. 5
0
def _ca_modify_order(self, order_meta, plugin_meta):
    """Sends a request to the Symantec CA to modify an order.

    Parameters needed for modifyOrder:
        PartnerOrderID - Needed to specify order
        PartnerCode - Needed to specify order
        ProductCode - Needed to specify order

    Also need a dict, order_meta with the parameters/values to modify.

    returns: tuple with success, error message, and can retry.
    """
    api = Symantec(self.username, self.password, self.url)

    order_details = {
        "PartnerOrderID": plugin_meta["PartnerOrderID"],
        "PartnerCode": plugin_meta["PartnerCode"],
        "ProductCode": plugin_meta["ProductCode"],
    }

    order_details.update(order_meta)

    try:
        api.validate_order_parameters(**order_details)
        return True, None, False
    except symantec_exceptions.SymantecError as e:
        return False, e, False
    except request_exceptions.RequestException as e:
        return False, e, True
Esempio n. 6
0
def _ca_get_order_status(self, plugin_meta):
    """Sends a request to the Symantec CA for details on an order.

    Parameters needed for GetOrderByPartnerOrderID:
    plugin_meta parameters: PartnerOrderId, PartnerCode

    If the order is complete, the Certificate is returned as a string.
    returns: tuple with success, error message, can retry,
             and the certificate (if available).
    """
    api = Symantec(self.username, self.password, self.url)

    order_details = {
        "PartnerOrderID": plugin_meta["PartnerOrderID"],
        "PartnerCode": plugin_meta["PartnerCode"],
        "ReturnCertificateInfo": "TRUE",
        "ReturnFulfillment": "TRUE",
        "ReturnCaCerts": "TRUE",
    }

    try:
        order_data = api.get_order_by_partner_order_id(**order_details)
        if order_data["OrderInfo"]["OrderState"] == "COMPLETED":
            ca = order_data["Fulfillment"]["CACertificates"]["CACertificate"]
            return True, None, False, ca["CACert"]
        return True, None, False, None
    except symantec_exceptions.SymantecError as e:
        return False, e, False, None
    except request_exceptions.RequestException as e:
        return False, e, True, None
Esempio n. 7
0
    def test_context_manager(self):
        api = Symantec("user", "p@ssw0rd")
        api.close = pretend.call_recorder(lambda: None)

        with api as ctx_api:
            assert ctx_api is api

        assert api.close.calls == [pretend.call()]
Esempio n. 8
0
 def test_basic_init(self):
     api = Symantec("user", "p@ssw0rd")
     assert api.url == "https://api.geotrust.com/webtrust/partner"
     assert isinstance(api.session, SymantecSession)
     assert isinstance(api.session.auth, SymantecAuth)
     assert api.session.auth.username == "user"
     assert api.session.auth.password == "p@ssw0rd"
Esempio n. 9
0
def _ca_create_order(self, order_meta, plugin_meta):
    """Creates an order with the Symantec CA.

    The PartnerOrderId and GeoTrustOrderId are returned and stored in
    plugin_meta. PartnerCode and ProductCode are also stored in plugin_meta
    for future use.

    All required order parameters must be stored as a dict in
    order_meta.
    Required fields are:
    PartnerCode, ProductCode, PartnerOrderId, OrganizationName,
    AddressLine1, City, Region, PostalCode, Country, OrganizationPhone
    ValidityPeriod, ServerCount, WebServerType, AdminContactFirstName,
    AdminContactLastName, AdminContactPhone, AdminContactEmail,
    AdminContactTitle, AdminContactAddressLine1, AdminContactCity,
    AdminContactRegion, AdminContactPostalCode, AdminContactCountry,
    BillingContact*,  TechContact*, and CSR.

    *The Billing and Tech contact information follows the same convention
    as the AdminContact fields.

    Optional Parameters: TechSameAsAdmin, BillSameAsAdmin, more options can be
    found in Symantec's API docs. Contact Symantec for the API document.

    :returns: tuple with success, error message, and can retry
    """

    api = Symantec(self.username, self.password, self.url)

    try:
        order_data = api.order(**order_meta)

        # GeotrustOrderId is used to handle emails from Symantec.
        # PartnerCode and ProductCode are being stored in plugin_meta for
        # convenience when calling _ca_get_order_status, _ca_modify_order, etc.
        plugin_meta["GeotrustOrderID"] = order_data["GeotrustOrderID"]
        plugin_meta["PartnerOrderID"] = order_data["PartnerOrderID"]
        plugin_meta["PartnerCode"] = order_meta["OrderDetails"]["PartnerCode"]
        plugin_meta["ProductCode"] = order_meta["OrderDetails"]["ProductCode"]
        return True, None, False
    except symantec_exceptions.SymantecError as e:
        return False, e, False
    except request_exceptions.RequestException as e:
        return False, e, True
Esempio n. 10
0
def _ca_create_order(self, order_meta, plugin_meta):
    """Creates an order with the Symantec CA.

    The PartnerOrderId and GeoTrustOrderId are returned and stored in
    plugin_meta. PartnerCode and ProductCode are also stored in plugin_meta
    for future use.

    All required order parameters must be stored as a dict in
    order_meta.
    Required fields are:
    PartnerCode, ProductCode, PartnerOrderId, OrganizationName,
    AddressLine1, City, Region, PostalCode, Country, OrganizationPhone
    ValidityPeriod, ServerCount, WebServerType, AdminContactFirstName,
    AdminContactLastName, AdminContactPhone, AdminContactEmail,
    AdminContactTitle, AdminContactAddressLine1, AdminContactCity,
    AdminContactRegion, AdminContactPostalCode, AdminContactCountry,
    BillingContact*,  TechContact*, and CSR.

    *The Billing and Tech contact information follows the same convention
    as the AdminContact fields.

    Optional Parameters: TechSameAsAdmin, BillSameAsAdmin, more options can be
    found in Symantec's API docs. Contact Symantec for the API document.

    :returns: tuple with success, error message, and can retry
    """

    api = Symantec(self.username, self.password, self.url)

    try:
        order_data = api.order(**order_meta)

        # GeotrustOrderId is used to handle emails from Symantec.
        # PartnerCode and ProductCode are being stored in plugin_meta for
        # convenience when calling _ca_get_order_status, _ca_modify_order, etc.
        plugin_meta["GeotrustOrderID"] = order_data["GeotrustOrderID"]
        plugin_meta["PartnerOrderID"] = order_data["PartnerOrderID"]
        plugin_meta["PartnerCode"] = order_meta["OrderDetails"]["PartnerCode"]
        plugin_meta["ProductCode"] = order_meta["OrderDetails"]["ProductCode"]
        return True, None, False
    except symantec_exceptions.SymantecError as e:
        return False, e, False
    except request_exceptions.RequestException as e:
        return False, e, True
Esempio n. 11
0
    def test_session_close(self):
        api = Symantec("user", "p@ssw0rd")
        api.session = pretend.stub(close=pretend.call_recorder(lambda: None))
        api.close()

        assert api.session.close.calls == [pretend.call()]
Esempio n. 12
0
 def test_init_with_url(self):
     api = Symantec("user", "p@ssw0rd", url="https://api.example.com/")
     assert api.url == "https://api.example.com/"
Esempio n. 13
0
def api():
    return Symantec("user", "p@ssw0rd")