@@ -37,6 +37,30 @@ def test_build_query(self):
3737 "scope" : "email calendar" ,
3838 }
3939
40+ def test_build_query_with_smtp_required_true (self ):
41+ config = {
42+ "foo" : "bar" ,
43+ "scope" : ["email" ],
44+ "smtp_required" : True ,
45+ }
46+ result = _build_query (config )
47+ assert result ["options" ] == "smtp_required"
48+ assert "smtp_required" not in result # must not leak into URL params
49+
50+ def test_build_query_smtp_required_false_omits_options (self ):
51+ config = {
52+ "foo" : "bar" ,
53+ "scope" : ["email" ],
54+ "smtp_required" : False ,
55+ }
56+ result = _build_query (config )
57+ assert "options" not in result
58+
59+ def test_build_query_smtp_required_omitted_omits_options (self ):
60+ config = {"foo" : "bar" , "scope" : ["email" ]}
61+ result = _build_query (config )
62+ assert "options" not in result
63+
4064 def test_build_query_with_pkce (self ):
4165 config = {
4266 "foo" : "bar" ,
@@ -52,6 +76,18 @@ def test_build_query_with_pkce(self):
5276 "code_challenge_method" : "s256" ,
5377 }
5478
79+ def test_build_query_with_pkce_and_smtp_required (self ):
80+ config = {
81+ "foo" : "bar" ,
82+ "scope" : ["email" ],
83+ "smtp_required" : True ,
84+ }
85+ result = _build_query_with_pkce (config , "secret-hash-123" )
86+ assert result ["options" ] == "smtp_required"
87+ assert "smtp_required" not in result # must not leak into URL params
88+ assert result ["code_challenge" ] == "secret-hash-123"
89+ assert result ["code_challenge_method" ] == "s256"
90+
5591 def test_build_query_with_admin_consent (self ):
5692 config = {
5793 "foo" : "bar" ,
0 commit comments