def test_canonical_string(self):
        """
        The hashes here were generated by running the same requests against
        boto.utils.canonical_string
        """
        def verify(hash, path, headers):
            req = Request.blank(path, headers=headers)
            self.assertEquals(hash,
                    hashlib.md5(swift3.canonical_string(req)).hexdigest())

        verify('6dd08c75e42190a1ce9468d1fd2eb787', '/bucket/object',
                {'Content-Type': 'text/plain', 'X-Amz-Something': 'test',
                 'Date': 'whatever'})

        verify('c8447135da232ae7517328f3429df481', '/bucket/object',
                {'Content-Type': 'text/plain', 'X-Amz-Something': 'test'})

        verify('bf49304103a4de5c325dce6384f2a4a2', '/bucket/object',
                {'content-type': 'text/plain'})

        verify('be01bd15d8d47f9fe5e2d9248cc6f180', '/bucket/object', {})

        verify('8d28cc4b8322211f6cc003256cd9439e', 'bucket/object',
                {'Content-MD5': 'somestuff'})

        verify('a822deb31213ad09af37b5a7fe59e55e', '/bucket/object?acl', {})

        verify('cce5dd1016595cb706c93f28d3eaa18f', '/bucket/object',
                {'Content-Type': 'text/plain', 'X-Amz-A': 'test',
                 'X-Amz-Z': 'whatever', 'X-Amz-B': 'lalala',
                 'X-Amz-Y': 'lalalalalalala'})

        verify('7506d97002c7d2de922cc0ec34af8846', '/bucket/object',
                {'Content-Type': None, 'X-Amz-Something': 'test'})

        verify('28f76d6162444a193b612cd6cb20e0be', '/bucket/object',
                {'Content-Type': None,
                 'X-Amz-Date': 'Mon, 11 Jul 2011 10:52:57 +0000',
                 'Date': 'Tue, 12 Jul 2011 10:52:57 +0000'})

        verify('ed6971e3eca5af4ee361f05d7c272e49', '/bucket/object',
                {'Content-Type': None,
                 'Date': 'Tue, 12 Jul 2011 10:52:57 +0000'})

        req1 = Request.blank('/', headers={'Content-Type': None,
                                           'X-Amz-Something': 'test'})
        req2 = Request.blank('/', headers={'Content-Type': '',
                                           'X-Amz-Something': 'test'})
        req3 = Request.blank('/', headers={'X-Amz-Something': 'test'})

        self.assertEquals(swift3.canonical_string(req1),
                swift3.canonical_string(req2))
        self.assertEquals(swift3.canonical_string(req2),
                swift3.canonical_string(req3))
 def verify(hash, path, headers):
     req = Request.blank(path, headers=headers)
     self.assertEquals(hash,
             hashlib.md5(swift3.canonical_string(req)).hexdigest())