~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/ec2/tests/test_client.py

  • Committer: kapil.thangavelu at canonical
  • Date: 2011-09-22 20:17:22 UTC
  • mfrom: (91.2.10 fix-s3-port)
  • mto: This revision was merged to the branch mainline in revision 99.
  • Revision ID: kapil.thangavelu@canonical.com-20110922201722-l4plcnk5wrr7eten
merge fix-s3-port-and-bucket-op [a=hazmat,jimbaker,spampas][r=therve][f=829609,824403]

Openstack compatibiity fixes.

 - S3 bucket operations use a trailing slash.
 - S3 Host and port are now configurable.
 - Security group parsing is now more forgiving.

Show diffs side-by-side

added added

removed removed

Lines of Context:
522
522
        d = ec2.describe_security_groups("WebServers")
523
523
        return d.addCallback(check_result)
524
524
 
 
525
    def test_describe_security_groups_with_openstack(self):
 
526
        """
 
527
        L{EC2Client.describe_security_groups} can work with openstack
 
528
        responses, which may lack proper port information for
 
529
        self-referencing group. Verifying that the response doesn't
 
530
        cause an internal error, workaround for nova launchpad bug
 
531
        #829609.
 
532
        """
 
533
        class StubQuery(object):
 
534
 
 
535
            def __init__(stub, action="", creds=None, endpoint=None,
 
536
                         other_params={}):
 
537
                self.assertEqual(action, "DescribeSecurityGroups")
 
538
                self.assertEqual(creds.access_key, "foo")
 
539
                self.assertEqual(creds.secret_key, "bar")
 
540
                self.assertEqual(other_params, {"GroupName.1": "WebServers"})
 
541
 
 
542
            def submit(self):
 
543
                return succeed(
 
544
                    payload.sample_describe_security_groups_with_openstack)
 
545
 
 
546
        def check_result(security_groups):
 
547
            [security_group] = security_groups
 
548
            self.assertEquals(security_group.name, "WebServers")
 
549
            self.assertEqual(
 
550
                security_group.allowed_groups[0].group_name, "WebServers")
 
551
 
 
552
        creds = AWSCredentials("foo", "bar")
 
553
        ec2 = client.EC2Client(creds, query_factory=StubQuery)
 
554
        d = ec2.describe_security_groups("WebServers")
 
555
        return d.addCallback(check_result)
 
556
 
525
557
    def test_create_security_group(self):
526
558
        """
527
559
        L{EC2Client.create_security_group} returns a C{Deferred} that