def RequestAuthenticated(method, path, body, hmac_secret): if _HMAC_HEADER not in request.headers: return False return hmac_utils.SecureBytesEqual( hmac_utils.CreateRequestHmac(ToBytes(method), ToBytes(path), ToBytes(body), ToBytes(hmac_secret)), ToBytes(b64decode(request.headers[_HMAC_HEADER])))
def SecureBytesEqual_ExceptionOnPy2Str_test(): ok_(hu.SecureBytesEqual('foo', 'foo'))
def SecureBytesEqual_ExceptionOnUnicode_test(): ok_(hu.SecureBytesEqual(u'foo', u'foo'))
def SecureBytesEqual_Empty_test(): ok_(hu.SecureBytesEqual(bytes(), bytes()))
def SecureBytesEqual_Basic_test(): ok_(hu.SecureBytesEqual(bytes(b'foo'), bytes(b'foo'))) ok_(not hu.SecureBytesEqual(bytes(b'foo'), bytes(b'goo')))