mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Removal of OAuth2 stuff from CLI
also from awxkit generally Remove login command
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
from http.client import NOT_FOUND
|
||||
import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
from requests import Response
|
||||
|
||||
from awxkit.api.pages import Base
|
||||
from awxkit.config import config
|
||||
|
||||
|
||||
@@ -22,38 +19,3 @@ def response(mocker):
|
||||
"access_token": "my_token",
|
||||
}
|
||||
return r
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("auth_creds", "url", "token"),
|
||||
[
|
||||
({"client_id": "foo", "client_secret": "bar"}, "/o/token/", "my_token"),
|
||||
({"client_id": "foo"}, "/o/token/", "my_token"),
|
||||
({}, "/api/gateway/v1/tokens/", "my_personal_token"),
|
||||
],
|
||||
)
|
||||
def test_get_oauth2_token_from_gateway(mocker: MockerFixture, response: Response, auth_creds, url, token):
|
||||
post = mocker.patch("requests.Session.post", return_value=response)
|
||||
base = Base()
|
||||
ret = base.get_oauth2_token(**auth_creds)
|
||||
assert post.call_count == 1
|
||||
assert post.call_args.args[0] == url
|
||||
assert ret == token
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("auth_creds", "url", "token"),
|
||||
[
|
||||
({"client_id": "foo", "client_secret": "bar"}, "/api/o/token/", "my_token"),
|
||||
({"client_id": "foo"}, "/api/o/token/", "my_token"),
|
||||
({}, "/api/v2/users/foo/personal_tokens/", "my_personal_token"),
|
||||
],
|
||||
)
|
||||
def test_get_oauth2_token_from_controller(mocker: MockerFixture, response: Response, auth_creds, url, token):
|
||||
type(response).ok = mocker.PropertyMock(side_effect=[False, True])
|
||||
post = mocker.patch("requests.Session.post", return_value=response)
|
||||
base = Base()
|
||||
ret = base.get_oauth2_token(**auth_creds)
|
||||
assert post.call_count == 2
|
||||
assert post.call_args.args[0] == url
|
||||
assert ret == token
|
||||
|
||||
@@ -10,11 +10,10 @@ ParseResult = namedtuple("ParseResult", ["port", "hostname", "secure"])
|
||||
|
||||
|
||||
def test_explicit_hostname():
|
||||
client = WSClient("token", "some-hostname", 556, False)
|
||||
client = WSClient(hostname="some-hostname", port=556, secure=False)
|
||||
assert client.port == 556
|
||||
assert client.hostname == "some-hostname"
|
||||
assert client._use_ssl == False
|
||||
assert client.token == "token"
|
||||
|
||||
|
||||
def test_websocket_suffix():
|
||||
@@ -35,7 +34,7 @@ def test_urlparsing(url, result):
|
||||
with patch("awxkit.ws.config") as mock_config:
|
||||
mock_config.base_url = url
|
||||
|
||||
client = WSClient("token")
|
||||
client = WSClient(hostname=None)
|
||||
assert client.port == result.port
|
||||
assert client.hostname == result.hostname
|
||||
assert client._use_ssl == result.secure
|
||||
|
||||
Reference in New Issue
Block a user