Skip to content

Commit 033b156

Browse files
committed
added test case for missing authctxt
1 parent 061aced commit 033b156

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_db.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,31 @@ def init():
5353
self.assertEqual(event.auth_id, "auth-id")
5454

5555
self.assertEqual(hello, "world")
56+
57+
def test_missing_auth_context(self):
58+
func = mock.Mock(__name__="example_func_no_auth")
59+
decorated_func = db_fn.on_value_created(reference="path")(func)
60+
61+
event = CloudEvent(
62+
attributes={
63+
"specversion": "1.0",
64+
"id": "id",
65+
"source": "source",
66+
"subject": "subject",
67+
"type": "type",
68+
"time": "2024-04-10T12:00:00.000Z",
69+
"instance": "instance",
70+
"ref": "ref",
71+
"firebasedatabasehost": "firebasedatabasehost",
72+
"location": "location",
73+
},
74+
data={"delta": "delta"},
75+
)
76+
77+
decorated_func(event)
78+
79+
func.assert_called_once()
80+
event_arg = func.call_args.args[0]
81+
self.assertIsNotNone(event_arg)
82+
self.assertEqual(event_arg.auth_type, "unknown")
83+
self.assertIsNone(event_arg.auth_id)

0 commit comments

Comments
 (0)