diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-08-04 17:59:22 +0200 |
---|---|---|
committer | John Villalovos <john@sodarock.com> | 2022-08-04 09:42:00 -0700 |
commit | 0040b4337bae815cfe1a06f8371a7a720146f271 (patch) | |
tree | 07800bfa7f6178480643dbd50cccb068fbbb2447 /tests/unit/test_gitlab.py | |
parent | af21a1856aa904f331859983493fe966d5a2969b (diff) | |
download | gitlab-0040b4337bae815cfe1a06f8371a7a720146f271.tar.gz |
feat(client): warn user on misconfigured URL in `auth()`
Diffstat (limited to 'tests/unit/test_gitlab.py')
-rw-r--r-- | tests/unit/test_gitlab.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py index 900a652..f9d4245 100644 --- a/tests/unit/test_gitlab.py +++ b/tests/unit/test_gitlab.py @@ -37,7 +37,11 @@ def resp_get_user(): return { "method": responses.GET, "url": "http://localhost/api/v4/user", - "json": {"id": 1, "username": "username"}, + "json": { + "id": 1, + "username": "username", + "web_url": "http://localhost/username", + }, "content_type": "application/json", "status": 200, } @@ -254,6 +258,24 @@ def test_gitlab_token_auth(gl, resp_get_user): assert isinstance(gl.user, gitlab.v4.objects.CurrentUser) +@responses.activate +def test_gitlab_auth_with_mismatching_url_warns(): + responses.add( + method=responses.GET, + url="http://first.example.com/api/v4/user", + json={ + "username": "test-user", + "web_url": "http://second.example.com/test-user", + }, + content_type="application/json", + status=200, + ) + gl = gitlab.Gitlab("http://first.example.com") + + with pytest.warns(UserWarning): + gl.auth() + + def test_gitlab_default_url(): gl = gitlab.Gitlab() assert gl.url == gitlab.const.DEFAULT_URL |