~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/testing/service.py

Merged 416109-arbitrary-endpoints [r=therve,jkakar] [f=416109].

The primary change of this branch is support of arbitrary endpoints (needed for
the support of Eucalyptus). In addition, the following was also performed:
 * Added a parse utility function from Twisted
 * Created a testing subpackage for use by txAWS unit tests
 * Created a service module for abstracting regions and associated
   serices/credentials

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from txaws.credentials import AWSCredentials
 
2
from txaws.service import AWSServiceEndpoint
 
3
from txaws.testing.ec2 import FakeEC2Client
 
4
 
 
5
 
 
6
class FakeAWSServiceRegion(object):
 
7
 
 
8
    instances = []
 
9
 
 
10
    def __init__(self, access_key="", secret_key="", uri=""):
 
11
        self.access_key = access_key
 
12
        self.secret_key = secret_key
 
13
        self.uri = uri
 
14
 
 
15
    def get_ec2_client(self, *args, **kwds):
 
16
 
 
17
        creds = AWSCredentials(access_key=self.access_key,
 
18
                               secret_key=self.secret_key)
 
19
        endpoint = AWSServiceEndpoint(uri=self.uri)
 
20
        return FakeEC2Client(creds, endpoint, instances=self.instances)