summaryrefslogtreecommitdiff
path: root/tests/unit/test_oauth.py
blob: ecc256be4f9a938aec450b9afbea416a1a84496d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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")