mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Remove oauth2client dependency in Google Assistant SDK (#85785)
Remove import oauth2client, inline 2 constants
This commit is contained in:
parent
28bea53afe
commit
8e26c048a7
@ -1,6 +1,4 @@
|
|||||||
"""application_credentials platform for Google Assistant SDK."""
|
"""application_credentials platform for Google Assistant SDK."""
|
||||||
import oauth2client
|
|
||||||
|
|
||||||
from homeassistant.components.application_credentials import AuthorizationServer
|
from homeassistant.components.application_credentials import AuthorizationServer
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
@ -8,8 +6,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
async def async_get_authorization_server(hass: HomeAssistant) -> AuthorizationServer:
|
async def async_get_authorization_server(hass: HomeAssistant) -> AuthorizationServer:
|
||||||
"""Return authorization server."""
|
"""Return authorization server."""
|
||||||
return AuthorizationServer(
|
return AuthorizationServer(
|
||||||
oauth2client.GOOGLE_AUTH_URI,
|
"https://accounts.google.com/o/oauth2/v2/auth",
|
||||||
oauth2client.GOOGLE_TOKEN_URI,
|
"https://oauth2.googleapis.com/token",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
"""Test the Google Assistant SDK config flow."""
|
"""Test the Google Assistant SDK config flow."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import oauth2client
|
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.google_assistant_sdk.const import DOMAIN
|
from homeassistant.components.google_assistant_sdk.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -12,6 +10,8 @@ from .conftest import CLIENT_ID, ComponentSetup
|
|||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
GOOGLE_AUTH_URI = "https://accounts.google.com/o/oauth2/v2/auth"
|
||||||
|
GOOGLE_TOKEN_URI = "https://oauth2.googleapis.com/token"
|
||||||
TITLE = "Google Assistant SDK"
|
TITLE = "Google Assistant SDK"
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ async def test_full_flow(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{oauth2client.GOOGLE_AUTH_URI}?response_type=code&client_id={CLIENT_ID}"
|
f"{GOOGLE_AUTH_URI}?response_type=code&client_id={CLIENT_ID}"
|
||||||
"&redirect_uri=https://example.com/auth/external/callback"
|
"&redirect_uri=https://example.com/auth/external/callback"
|
||||||
f"&state={state}&scope=https://www.googleapis.com/auth/assistant-sdk-prototype"
|
f"&state={state}&scope=https://www.googleapis.com/auth/assistant-sdk-prototype"
|
||||||
"&access_type=offline&prompt=consent"
|
"&access_type=offline&prompt=consent"
|
||||||
@ -47,7 +47,7 @@ async def test_full_flow(
|
|||||||
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
||||||
|
|
||||||
aioclient_mock.post(
|
aioclient_mock.post(
|
||||||
oauth2client.GOOGLE_TOKEN_URI,
|
GOOGLE_TOKEN_URI,
|
||||||
json={
|
json={
|
||||||
"refresh_token": "mock-refresh-token",
|
"refresh_token": "mock-refresh-token",
|
||||||
"access_token": "mock-access-token",
|
"access_token": "mock-access-token",
|
||||||
@ -112,7 +112,7 @@ async def test_reauth(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{oauth2client.GOOGLE_AUTH_URI}?response_type=code&client_id={CLIENT_ID}"
|
f"{GOOGLE_AUTH_URI}?response_type=code&client_id={CLIENT_ID}"
|
||||||
"&redirect_uri=https://example.com/auth/external/callback"
|
"&redirect_uri=https://example.com/auth/external/callback"
|
||||||
f"&state={state}&scope=https://www.googleapis.com/auth/assistant-sdk-prototype"
|
f"&state={state}&scope=https://www.googleapis.com/auth/assistant-sdk-prototype"
|
||||||
"&access_type=offline&prompt=consent"
|
"&access_type=offline&prompt=consent"
|
||||||
@ -123,7 +123,7 @@ async def test_reauth(
|
|||||||
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
||||||
|
|
||||||
aioclient_mock.post(
|
aioclient_mock.post(
|
||||||
oauth2client.GOOGLE_TOKEN_URI,
|
GOOGLE_TOKEN_URI,
|
||||||
json={
|
json={
|
||||||
"refresh_token": "mock-refresh-token",
|
"refresh_token": "mock-refresh-token",
|
||||||
"access_token": "updated-access-token",
|
"access_token": "updated-access-token",
|
||||||
@ -181,7 +181,7 @@ async def test_single_instance_allowed(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{oauth2client.GOOGLE_AUTH_URI}?response_type=code&client_id={CLIENT_ID}"
|
f"{GOOGLE_AUTH_URI}?response_type=code&client_id={CLIENT_ID}"
|
||||||
"&redirect_uri=https://example.com/auth/external/callback"
|
"&redirect_uri=https://example.com/auth/external/callback"
|
||||||
f"&state={state}&scope=https://www.googleapis.com/auth/assistant-sdk-prototype"
|
f"&state={state}&scope=https://www.googleapis.com/auth/assistant-sdk-prototype"
|
||||||
"&access_type=offline&prompt=consent"
|
"&access_type=offline&prompt=consent"
|
||||||
@ -193,7 +193,7 @@ async def test_single_instance_allowed(
|
|||||||
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
assert resp.headers["content-type"] == "text/html; charset=utf-8"
|
||||||
|
|
||||||
aioclient_mock.post(
|
aioclient_mock.post(
|
||||||
oauth2client.GOOGLE_TOKEN_URI,
|
GOOGLE_TOKEN_URI,
|
||||||
json={
|
json={
|
||||||
"refresh_token": "mock-refresh-token",
|
"refresh_token": "mock-refresh-token",
|
||||||
"access_token": "mock-access-token",
|
"access_token": "mock-access-token",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user