Skip to content

Commit 9763f5e

Browse files
committed
Fix style
1 parent 1a31c09 commit 9763f5e

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

tests/v3/test_skip_signature_verification.py

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from linebot.v3.exceptions import InvalidSignatureError
2323

24+
2425
class TestWebhookParserWithSkipSignatureVerification(unittest.TestCase):
2526
def setUp(self):
2627
self.parser = WebhookParser('channel_secret')
@@ -40,6 +41,7 @@ def test_parse_with_invalid_signature(self):
4041
except InvalidSignatureError:
4142
self.fail("parse() raised InvalidSignatureError unexpectedly!")
4243

44+
4345
class TestWebhookHandlerWithSkipSignatureVerification(unittest.TestCase):
4446
def setUp(self):
4547
self.handler = WebhookHandler('channel_secret')
@@ -56,7 +58,31 @@ def default_with_skip(event):
5658
self.handler_with_skip_called = True
5759

5860
def test_handle_with_invalid_signature(self):
59-
body = '{"events": [{"type": "message", "message": {"type": "text", "id": "123", "text": "test"}, "timestamp": 1462629479859, "source": {"type": "user", "userId": "U123"}, "replyToken": "reply_token", "mode": "active", "webhookEventId": "test_id", "deliveryContext": {"isRedelivery": false}}]}'
61+
body = """
62+
{
63+
"events": [
64+
{
65+
"type": "message",
66+
"message": {
67+
"type": "text",
68+
"id": "123",
69+
"text": "test"
70+
},
71+
"timestamp": 1462629479859,
72+
"source": {
73+
"type": "user",
74+
"userId": "U123"
75+
},
76+
"replyToken": "reply_token",
77+
"mode": "active",
78+
"webhookEventId": "test_id",
79+
"deliveryContext": {
80+
"isRedelivery": false
81+
}
82+
}
83+
]
84+
}
85+
"""
6086
signature = 'invalid_signature'
6187

6288
# Should raise InvalidSignatureError when skip_signature_verification is False (default)
@@ -76,7 +102,31 @@ def test_handle_with_invalid_signature(self):
76102
self.assertTrue(self.handler_with_skip_called)
77103

78104
def test_dynamic_skip_signature_verification(self):
79-
body = '{"events": [{"type": "message", "message": {"type": "text", "id": "123", "text": "test"}, "timestamp": 1462629479859, "source": {"type": "user", "userId": "U123"}, "replyToken": "reply_token", "mode": "active", "webhookEventId": "test_id", "deliveryContext": {"isRedelivery": false}}]}'
105+
body = """
106+
{
107+
"events": [
108+
{
109+
"type": "message",
110+
"message": {
111+
"type": "text",
112+
"id": "123",
113+
"text": "test"
114+
},
115+
"timestamp": 1462629479859,
116+
"source": {
117+
"type": "user",
118+
"userId": "U123"
119+
},
120+
"replyToken": "reply_token",
121+
"mode": "active",
122+
"webhookEventId": "test_id",
123+
"deliveryContext": {
124+
"isRedelivery": false
125+
}
126+
}
127+
]
128+
}
129+
"""
80130
signature = 'invalid_signature'
81131
skip_flag = [False]
82132

@@ -111,6 +161,6 @@ def default_dynamic(event):
111161
# Handler should be called now
112162
self.assertTrue(dynamic_handler_called[0])
113163

164+
114165
if __name__ == '__main__':
115166
unittest.main()
116-

0 commit comments

Comments
 (0)