sources/oauth: fix link not being saved (#10374)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		| @ -309,7 +309,7 @@ class SourceFlowManager: | ||||
|         # When request isn't authenticated we jump straight to auth | ||||
|         if not self.request.user.is_authenticated: | ||||
|             return self.handle_auth(connection) | ||||
|         # Connection has already been saved | ||||
|         connection.save() | ||||
|         Event.new( | ||||
|             EventAction.SOURCE_LINKED, | ||||
|             message="Linked Source", | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| """test OAuth Source""" | ||||
|  | ||||
| from json import loads | ||||
| from pathlib import Path | ||||
| from time import sleep | ||||
| from typing import Any | ||||
| @ -194,3 +195,41 @@ class TestSourceOAuth2(SeleniumTestCase): | ||||
|         self.driver.get(self.if_user_url("/settings")) | ||||
|  | ||||
|         self.assert_user(User(username="foo", name="admin", email="admin@example.com")) | ||||
|  | ||||
|     @retry() | ||||
|     @apply_blueprint( | ||||
|         "default/flow-default-authentication-flow.yaml", | ||||
|         "default/flow-default-invalidation-flow.yaml", | ||||
|     ) | ||||
|     @apply_blueprint( | ||||
|         "default/flow-default-source-authentication.yaml", | ||||
|         "default/flow-default-source-enrollment.yaml", | ||||
|         "default/flow-default-source-pre-authentication.yaml", | ||||
|     ) | ||||
|     def test_oauth_link(self): | ||||
|         """test OAuth Source link OIDC""" | ||||
|         self.create_objects() | ||||
|         self.driver.get(self.live_server_url) | ||||
|         self.login() | ||||
|  | ||||
|         self.driver.get( | ||||
|             self.url("authentik_sources_oauth:oauth-client-login", source_slug=self.slug) | ||||
|         ) | ||||
|  | ||||
|         # Now we should be at the IDP, wait for the login field | ||||
|         self.wait.until(ec.presence_of_element_located((By.ID, "login"))) | ||||
|         self.driver.find_element(By.ID, "login").send_keys("admin@example.com") | ||||
|         self.driver.find_element(By.ID, "password").send_keys("password") | ||||
|         self.driver.find_element(By.ID, "password").send_keys(Keys.ENTER) | ||||
|  | ||||
|         # Wait until we're logged in | ||||
|         self.wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "button[type=submit]"))) | ||||
|         self.driver.find_element(By.CSS_SELECTOR, "button[type=submit]").click() | ||||
|  | ||||
|         self.driver.get(self.url("authentik_api:usersourceconnection-list") + "?format=json") | ||||
|         body_json = loads(self.driver.find_element(By.CSS_SELECTOR, "pre").text) | ||||
|         results = body_json["results"] | ||||
|         self.assertEqual(len(results), 1) | ||||
|         connection = results[0] | ||||
|         self.assertEqual(connection["source"]["slug"], self.slug) | ||||
|         self.assertEqual(connection["user"], self.user.pk) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Jens L
					Jens L