cloudkeep/symantecssl — pull request #3 by dstufft (2014-05-29 18:59:00+00:00)
Title: Implement GetOrderByPartnerID and ModifyOrder commands

These can be used as thus:

```python
import time

from symantecssl import Symantec, SymantecError, order

api_url = "https://test-api.geotrust.com/webtrust/partner"
partner_code = "..."

api = Symantec("...", "...", url=api_url)

d = api.order(
partnercode=partner_code,
productcode=order.ProductCode.SSL123,
organizationname="MyOrg",
addressline1="5000 Walzem",
city="San Antonio",
region="TX",
postalcode="78218",
country="US",
organizationphone="2103124000",
validityperiod=order.ValidityPeriod.OneYear,
serverCount="1",
webservertype=order.WebServer.ApacheOpenSSL,
admincontactfirstname="John",
admincontactlastname="Doe",
admincontactphone="2103122400",
admincontactemail="someone@email.com",
admincontacttitle="Caesar",
admincontactaddressline1="123 Road",
admincontactcity="San Antonio",
admincontactregion="TX",
admincontactpostalcode="78218",
admincontactcountry="US",
techsameasadmin=True,
billsameastech=True,
approveremail="admin@testingsymantecssl.com",
csr="""
-----BEGIN CERTIFICATE REQUEST-----
MIICzDCCAbQCAQAwYzELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMRQwEgYD
VQQHEwtTYW4gQW50b25pbzENMAsGA1UEChMEVGVzdDEfMB0GA1UEAxMWdGVzdGlu
Z3N5bWFudGVjc3NsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AOO5cCIKIGegzQDEK/Ng3+6EdY4H7ZFAvSsFFdDTXfckpBznm/j3sbjKv7LlnyoQ
SVEhhr/mErtXfe19mSPCzJ3jUSotONnKpjvbZSLn7xJ4tZzIxS5OOY/VeLQc0V7A
jheswmFN9+BFHMjNHEYc8KzPEe67BS2exiagwUQD+g55bQr0iZnKIYRuDQ8X5Kaq
ivPDfGFNCo29Mwyzo6sy6fFjqFzul/kjSmIRizaxuPT6zLKAMCLIkpxVp+YPA7tB
QORu+UvgTtsIerG8EM4SQC53Ctwxw+V2lH5t9UH4UtX+IEDn8pUVbgNHfrt8TPqZ
ynsCKdwJQ7VmgK8wwAdM7r0CAwEAAaAkMCIGCSqGSIb3DQEJDjEVMBMwEQYJYIZI
AYb4QgEBBAQDAgZAMA0GCSqGSIb3DQEBBQUAA4IBAQCdF9dZg6KH4VgWTJcPskCX
feIAc+BU+7B4eA4RS7StuABz+x6ff39R9g62IM6ppIZU3VKmb3jClD/xPjHTrsiE
0WgTG7iWBF6oOyqiTX5/w6KlWddaBq/m2YzhnpDb/IQJhxRgxt0alHBtlcglzPms
CbbHMcSlYXIr32S20rhS1oaiI0aIPjbbEjzSViFN7IIDUCXPgb0DgQXKrZZpT9fh
+6MlhlabtkSDrRzZXOeOFOxQBRjRlv/ZiwGhfD0u/xTnKyOU8p8XFHRFpg/zRyBf
M7HcFYsHVIgPB1M303pLtdN91Iig7D8LLIMDl9p+HTEpNLmAVefUeq20hPZTVee6
-----END CERTIFICATE REQUEST-----
""",
)

print(api.get_order_by_partner_order_id(
partnercode=partner_code,
partnerorderid=d["PartnerOrderID"],
))

try:
api.modify_order(
partnercode=partner_code,
productcode=order.ProductCode.SSL123,
partnerorderid=d["PartnerOrderID"],
modifyorderoperation=order.ModifyOperation.Approve,
)
except SymantecError:
pass # This will always fail a security review.

api.modify_order(
partnercode=partner_code,
productcode=order.ProductCode.SSL123,
partnerorderid=d["PartnerOrderID"],
modifyorderoperation=order.ModifyOperation.PushState,
)

while True:
details = api.get_order_by_partner_order_id(
partnercode=partner_code,
partnerorderid=d["PartnerOrderID"],
)

print(details)

if details["OrderState"] not in {
"WF_DOMAIN_APPROVAL",
"WF_MANUAL_VETTING",
}:
break

time.sleep(60)
```

The above code will print out the order details every minute until it has been approved. This generally takes 15+ minutes.

This PR also renames the ``SymantecValueError`` to ``SymantecError`` as it no longer makes sense for it to be a ``ValueError`` subclass. It also reduces the boiler plate in the core tests.