def test_signature(self): from faws.sign.v4 import signature derived_signing_key = b'\x98\xf1\xd8\x89\xfe\xc4\xf4B\x1a\xdcR+\xab\x0c\xe1\xf8.i)\xc2b\xed\x15\xe5\xa9L\x90\xef\xd1\xe3\xb0\xe7' str_to_sign = '''AWS4-HMAC-SHA256 20110909T233600Z 20110909/us-east-1/iam/aws4_request 3511de7e95d28ecd39e9513b642aee07e54f4941150d8df8bf94b328ef7e55e2''' expected = 'ced6826de92d2bdeed8f846f0bf508e8559e98e4b0199114b84c54174deb456c' actual = signature(derived_signing_key, str_to_sign) self.assertSequenceEqual(expected, actual)
def full_params(self, method, action, params, now): from faws.sign.v4 import ( signature, cr_hash, signing_key, string_to_sign, ) expires = now + datetime.timedelta(minutes=10) params = dict(params) params.update({ 'Action' : action, 'Version' : '2013-02-01', }) params['Signature'] = signature( signing_key(self.creds.secret_key, now, self.creds.region, 'ec2'), string_to_sign(self.creds.region, 'ec2', cr_hash(method, self.url, params, now), now))