Add unit tests (#133)
* Add initial test & add pipeline * Add very basic YAML config tests * Add coverage reporting * Add some webserver & template loading tests * Add test cases for the helpers * Implement initial OIDC server tests * Test codestore & discovery checker * Test basics of the config flow * Add test for the HA auth provider * Cleaned up tests & test injection
This commit is contained in:
committed by
GitHub
parent
5714e844a7
commit
404d2451df
@@ -67,6 +67,4 @@ class OIDCCallbackView(HomeAssistantView):
|
||||
return web.Response(text=view_html, content_type="text/html")
|
||||
|
||||
code = await self.oidc_provider.async_save_user_info(user_details)
|
||||
return web.HTTPFound(
|
||||
get_url("/auth/oidc/finish?code=" + code, self.force_https)
|
||||
)
|
||||
raise web.HTTPFound(get_url("/auth/oidc/finish?code=" + code, self.force_https))
|
||||
|
||||
@@ -40,7 +40,7 @@ class OIDCFinishView(HomeAssistantView):
|
||||
return web.Response(text="No code received", status=500)
|
||||
|
||||
# Return redirect to the main page for sign in with a cookie
|
||||
return web.HTTPFound(
|
||||
raise web.HTTPFound(
|
||||
location="/?storeToken=true",
|
||||
headers={
|
||||
# Set a cookie to enable autologin on only the specific path used
|
||||
|
||||
@@ -25,10 +25,14 @@ class OIDCRedirectView(HomeAssistantView):
|
||||
"""Receive response."""
|
||||
|
||||
redirect_uri = get_url("/auth/oidc/callback", self.force_https)
|
||||
auth_url = await self.oidc_client.async_get_authorization_url(redirect_uri)
|
||||
|
||||
if auth_url:
|
||||
return web.HTTPFound(auth_url)
|
||||
try:
|
||||
auth_url = await self.oidc_client.async_get_authorization_url(redirect_uri)
|
||||
|
||||
if auth_url:
|
||||
raise web.HTTPFound(auth_url)
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
view_html = await get_view(
|
||||
"error",
|
||||
|
||||
@@ -23,7 +23,7 @@ class OIDCWelcomeView(HomeAssistantView):
|
||||
"""Receive response."""
|
||||
|
||||
if not self.is_enabled:
|
||||
return web.HTTPTemporaryRedirect(get_url("/", self.force_https))
|
||||
raise web.HTTPTemporaryRedirect(get_url("/", self.force_https))
|
||||
|
||||
view_html = await get_view("welcome", {"name": self.name})
|
||||
return web.Response(text=view_html, content_type="text/html")
|
||||
|
||||
Reference in New Issue
Block a user