diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-01-19 23:05:47 +0100 |
---|---|---|
committer | Nejc Habjan <nejc.habjan@siemens.com> | 2023-02-16 20:22:10 +0100 |
commit | be7745dc3dfee64d453287ed7d350adc7e5cadae (patch) | |
tree | d2c2134b539893c73b6c6ee31242f3b995e0eb16 /tests/unit/test_oauth.py | |
parent | 1da7c53fd3476a1ce94025bb15265f674af40e1a (diff) | |
download | gitlab-feat/oauth2-resource-password-flow.tar.gz |
feat(client): replace basic auth with OAuth ROPC flowfeat/oauth2-resource-password-flow
Diffstat (limited to 'tests/unit/test_oauth.py')
-rw-r--r-- | tests/unit/test_oauth.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/test_oauth.py b/tests/unit/test_oauth.py new file mode 100644 index 0000000..ecc256b --- /dev/null +++ b/tests/unit/test_oauth.py @@ -0,0 +1,27 @@ +import pytest + +from gitlab.oauth import PasswordCredentials + + +def test_password_credentials_without_password_raises(): + with pytest.raises(TypeError, match="missing 1 required positional argument"): + PasswordCredentials("username") + + +def test_password_credentials_with_client_id_without_client_secret_raises(): + with pytest.raises(TypeError, match="client_id and client_secret must be defined"): + PasswordCredentials( + "username", + "password", + client_id="abcdef123456", + ) + + +def test_password_credentials_with_client_credentials_sets_basic_auth(): + credentials = PasswordCredentials( + "username", + "password", + client_id="abcdef123456", + client_secret="123456abcdef", + ) + assert credentials.basic_auth == ("abcdef123456", "123456abcdef") |