|
13 | 13 | import shutil |
14 | 14 | import tempfile |
15 | 15 |
|
16 | | -import requests |
17 | | - |
18 | 16 | import tests |
19 | 17 | import tests.mockbackend |
20 | 18 | import tests.utils |
@@ -116,13 +114,17 @@ def test_authfiles_saving(monkeypatch): |
116 | 114 | bzapi.cert = "foo-fake-path" |
117 | 115 | backend = bzapi._backend # pylint: disable=protected-access |
118 | 116 | bsession = backend._bugzillasession # pylint: disable=protected-access |
| 117 | + btokencache = bzapi._tokencache # pylint: disable=protected-access |
119 | 118 |
|
120 | 119 | # token testing, with repetitions to hit various code paths |
121 | | - bsession.set_token_value(None) |
122 | | - bsession.set_token_value("MY-FAKE-TOKEN") |
123 | | - bsession.set_token_value("MY-FAKE-TOKEN") |
124 | | - bsession.set_token_value(None) |
125 | | - bsession.set_token_value("MY-FAKE-TOKEN") |
| 120 | + btokencache.set_value(bzapi.url, None) |
| 121 | + assert "Bugzilla_token" not in bsession.get_auth_params() |
| 122 | + btokencache.set_value(bzapi.url, "MY-FAKE-TOKEN") |
| 123 | + assert bsession.get_auth_params()["Bugzilla_token"] == "MY-FAKE-TOKEN" |
| 124 | + btokencache.set_value(bzapi.url, "MY-FAKE-TOKEN") |
| 125 | + btokencache.set_value(bzapi.url, None) |
| 126 | + assert "Bugzilla_token" not in bsession.get_auth_params() |
| 127 | + btokencache.set_value(bzapi.url, "MY-FAKE-TOKEN") |
126 | 128 |
|
127 | 129 | dirname = os.path.dirname(__file__) + "/data/authfiles/" |
128 | 130 | output_token = dirname + "output-token.txt" |
@@ -155,9 +157,8 @@ def test_authfiles_nowrite(): |
155 | 157 | # Setting values tokenfile is None, should be fine |
156 | 158 | bzapi = tests.mockbackend.make_bz(bz_kwargs={"use_creds": False}) |
157 | 159 | bzapi.connect("https://example.com/foo") |
158 | | - backend = bzapi._backend # pylint: disable=protected-access |
159 | | - bsession = backend._bugzillasession # pylint: disable=protected-access |
| 160 | + btokencache = bzapi._tokencache # pylint: disable=protected-access |
160 | 161 | rcfile = bzapi._rcfile # pylint: disable=protected-access |
161 | 162 |
|
162 | | - bsession.set_token_value("NEW-TOKEN-VALUE") |
| 163 | + btokencache.set_value(bzapi.url, "NEW-TOKEN-VALUE") |
163 | 164 | assert rcfile.save_api_key(bzapi.url, "fookey") is None |
0 commit comments