fix tests involving HttpDate

This commit is contained in:
Izalia Mae 2024-03-21 23:13:29 -04:00
parent cea5563e79
commit 13e25959fa
3 changed files with 7 additions and 7 deletions

View file

@ -24,7 +24,7 @@ MESSAGES = {
"https://social.example.com/media/header/cheese_wedge.bmp",
following = "https://social.example.com/user/cheese_wedge/following",
followers = "https://social.example.com/user/cheese_wedge/followers",
created = aputils.HttpDate.parse("2019-11-16T00:00:00Z")
created = aputils.MessageDate.parse("2019-11-16T00:00:00Z")
)
}
@ -62,7 +62,7 @@ RAW_MESSAGES = {
},
"following": "https://social.example.com/user/cheese_wedge/following",
"followers": "https://social.example.com/user/cheese_wedge/followers",
"created": aputils.HttpDate.parse("2019-11-16T00:00:00Z"),
"created": aputils.MessageDate.parse("2019-11-16T00:00:00Z"),
"icon": {
"type": "Image",
"mediaType": "image/bmp",

View file

@ -11,13 +11,13 @@ BODY_DIGEST = "SHA-256=NaQWaYfGtWY/aniiFBuMuASqbmGEes5vsPTFaRKuTGI="
class MiscTest(unittest.TestCase):
def test_httpdate(self):
output = aputils.HttpDate(2022, 11, 25, 6, 9, 42, tzinfo=timezone.utc)
data = "2022-11-25T06:09:42Z"
data = "Fri, 25 Nov 2022 06:09:42 GMT"
self.assertEqual(output.to_string(), data)
def test_httpdate_parse(self):
output = aputils.HttpDate.parse("2022-11-25T06:09:42Z")
output = aputils.HttpDate.parse("Fri, 25 Nov 2022 06:09:42 GMT")
data = aputils.HttpDate(2022, 11, 25, 6, 9, 42, tzinfo=timezone.utc)
self.assertEqual(output, data)

View file

@ -28,8 +28,8 @@ class SignerTest(unittest.TestCase):
def test_sign_get(self):
output = signer.sign_headers('GET', url, headers={'date': date})
data = {
'date': "2022-11-25T06:09:42Z",
'signature': "keyId=\"https://social.example.com/users/merpinator#main-key\",algorithm=\"hs2019\",headers=\"(request-target) host date (created) (expires)\",created=\"1669374582\",expires=\"1669396182\",signature=\"MYTeu9yPtSfHyDSB+cgJrejRBWTyRfwZkC2uPX4IO4w6UgNMOp438KWx9oQoIKqc6DKGLarJO9OPI2sGGxJfBnC/+kljgHgLGv/CxMjCw1nIrQcFP+cLbd3O34vw2H4Q3MthDFk7pWxDQK4BfXU8TCwz/SmgHEKBiO7QvlfG/MvY+WD7WdkyulriCQY+UpEc/YGy1jvz6pmqto1wxHYI412hCcD7wdEM9KQLzs5MRr3KuHF+J+j1mBu+so5dnRKXxAlv6yiblqiFXGIJpSsNvR94MkihPxzEFs7857pEVJxVXHpppqHsKEDK0EhflL5v9TlFYklzxJuRv/tXi6rXpA==\""
'date': "Fri, 25 Nov 2022 06:09:42 GMT",
'signature': "keyId=\"https://social.example.com/users/merpinator#main-key\",algorithm=\"hs2019\",headers=\"(request-target) host date (created) (expires)\",created=\"1669374582\",expires=\"1669396182\",signature=\"EpEvJ3N1mVvQYAfM05UxLuAF5TGCv59dYxcI34TFTEHqOr/2wDnQLQTgE1+SpFi8k8zUCPChvT/M4OneSZTQjV8JAa0YGA1g70kq6miQj0vXTMHZOGnBSgUko/B0Io72lLP+Kj+LMLUnQ9WpYvbmlwoilptAD52hLitYqQoqyeEdn8Zm7IVBGc46VVBO0iZgLAofp0WFvpyzLqCxByvGBv2IJ083QBlgN88k5GFkQYyRK9iOKT2+00rKlKCzGjrvjxrFWQ8ZLdZJJxA9BmbRYq4avwyd6kOTk/hWzRSm60doCsR+fXTNiRNteNhhOUJMpugzak/7HFus1vVzvNO91w==\""
}
self.assertEqual(output, data)
@ -39,7 +39,7 @@ class SignerTest(unittest.TestCase):
def test_verify_exception(self):
output = signer.sign_headers("GET", url, headers={'date': date})
data = {
'date': "2022-11-25T06:09:42Z",
'date': "Fri, 25 Nov 2022 06:09:42 GMT",
'signature': "keyId=\"https://social.example.com/users/merpinator#main-key\",algorithm=\"hs2019\",headers=\"(request-target) host date (created) (expires)\",created=\"1669374582\",expires=\"1669396182\",signature=\"EpEvJ3N1mVvQYAfM05UxLuAF5TGCv59dYxcI34TFTEHqOr/2wDnQLQTgE1+SpFi8k8zUCPChvT/M4OneSZTQjV8JAa0YGA1g70kq6miQj0vXTMHZOGnBSgUko/B0Io72lLP+Kj+LMLUnQ9WpYvbmlwoilptAD52hLitYqQoqyeEdn8Zm7IVBGc46VVBO0iZgLAofp0WFvpyzLqCxByvGBv2IJ083QBlgN88k5GFkQYyRK9iOKT2+00rKlKCzGjrvjxrFWQ8ZLdZJJxA9BmbRYq4avwyd6kOTk/hWzRSm60doCsR+fXTNiRNteNhhOUJMpugzak/7HFus1vVzvNO91w==\""
}