@@ -109,7 +109,6 @@ def test_authenticator_token():
109
109
auth .setToken ("susie" , "ss-token" )
110
110
auth .setToken ("hobbes" , "hbs-token" )
111
111
auth .setToken ("moe" , "m-token" )
112
- auth .setPass ("rosalyn" , "rsln-pass" )
113
112
kwargs = {}
114
113
auth .setAuth ("calvin" , kwargs , auth = "bearer" )
115
114
assert kwargs ["headers" ]["Authorization" ] == "Bearer clv-token"
@@ -133,6 +132,14 @@ def test_authenticator_token():
133
132
except ft .FlaskTesterError :
134
133
assert True , "error raised"
135
134
# rosalyn as a password, but no password carrier is allowed
135
+ try :
136
+ auth .setPass ("rosalyn" , "rsln-pass" )
137
+ assert False , "must raise an error" # pragma: no cover
138
+ except ft .AuthError :
139
+ assert True , "error raised"
140
+ # force to trigger later errors
141
+ auth ._has_pass = True
142
+ auth .setPass ("rosalyn" , "rsln-pass" )
136
143
try :
137
144
kwargs = {}
138
145
auth .setAuth ("rosalyn" , kwargs )
@@ -147,7 +154,6 @@ def test_authenticator_password():
147
154
auth .setPass ("hobbes" , "hbs-pass" )
148
155
auth .setPass ("moe" , "m-pass" )
149
156
auth .setPass ("rosalyn" , "rsln-pass" )
150
- auth .setToken ("susie" , "ss-token" )
151
157
kwargs = {}
152
158
auth .setAuth ("calvin" , kwargs , auth = "basic" )
153
159
assert kwargs ["auth" ] == ("calvin" , "clv-pass" )
@@ -164,6 +170,14 @@ def test_authenticator_password():
164
170
auth .setAuth ("hobbes" , kwargs , auth = "fake" )
165
171
assert kwargs ["json" ]["LOGIN" ] == "hobbes"
166
172
# susie as a token, but no token carrier is allowed
173
+ try :
174
+ auth .setToken ("susie" , "ss-token" )
175
+ assert False , "must raise an error" # pragma: no cover
176
+ except ft .FlaskTesterError :
177
+ assert True , "error raised"
178
+ # force to trigger later error
179
+ auth ._has_token = True
180
+ auth .setToken ("susie" , "ss-token" )
167
181
try :
168
182
kwargs = {}
169
183
auth .setAuth ("susie" , kwargs )
0 commit comments