def test_signing_key(self): # from example on http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html from faws.sign.v4 import signing_key secret_key = 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY' when = datetime.datetime.strptime('20110909T233600Z', DATETIME_F) region = 'us-east-1' service = 'iam' expected = 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' actual = signing_key(secret_key, when, region, service) self.assertEqual(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))