Skip to content

Commit

Permalink
Fix ruff errros
Browse files Browse the repository at this point in the history
  • Loading branch information
letzdoo-js committed Oct 28, 2024
1 parent 6534866 commit 3a89c8b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
12 changes: 6 additions & 6 deletions auth_saml/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _auth_saml_request_link(self, provider: models.Model):
redirect = request.params.get("redirect")
if redirect:
params["redirect"] = redirect
return "/auth_saml/get_auth_request?%s" % werkzeug.urls.url_encode(params)
return f"/auth_saml/get_auth_request?{werkzeug.urls.url_encode(params)}"

@http.route()
def web_client(self, s_action=None, **kw):
Expand Down Expand Up @@ -238,14 +238,14 @@ def signin(self, **kw):
if redirect:
url = redirect
elif action:
url = "/#action=%s" % action
url = f"/#action={action}"
elif menu:
url = "/#menu_id=%s" % menu
url = f"/#menu_id={menu}"

credentials_dict = {
'login': credentials[1],
'token': credentials[2],
'type' : 'saml_token',
"login": credentials[1],
"token": credentials[2],
"type": "saml_token",
}
pre_uid = request.session.authenticate(dbname, credentials_dict)
resp = request.redirect(_get_login_redirect_url(pre_uid, url), 303)
Expand Down
2 changes: 1 addition & 1 deletion auth_saml/models/auth_saml_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _compute_sp_metadata_url(self):
qs = urllib.parse.urlencode({"p": record.id, "d": self.env.cr.dbname})

record.sp_metadata_url = urllib.parse.urljoin(
base_url, ("/auth_saml/metadata?%s" % qs)
base_url, (f"/auth_saml/metadata?{qs}")
)

def _get_cert_key_path(self, field="sp_pem_public"):
Expand Down
12 changes: 5 additions & 7 deletions auth_saml/tests/fake_idp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@
"aa": {
"endpoints": {
"attribute_service": [
("%s/aap" % BASE, BINDING_HTTP_POST),
(f"{BASE}/aap", BINDING_HTTP_POST),
]
},
},
"aq": {
"endpoints": {
"authn_query_service": [("%s/aqs" % BASE, BINDING_HTTP_POST)]
},
"endpoints": {"authn_query_service": [(f"{BASE}/aqs", BINDING_HTTP_POST)]},
},
"idp": {
"endpoints": {
"single_sign_on_service": [
("%s/sso/redirect" % BASE, BINDING_HTTP_REDIRECT),
("%s/sso/post" % BASE, BINDING_HTTP_POST),
(f"{BASE}/sso/redirect", BINDING_HTTP_REDIRECT),
(f"{BASE}/sso/post", BINDING_HTTP_POST),
],
},
"policy": {
Expand Down Expand Up @@ -87,7 +85,7 @@ def _unpack(self, ver="SAMLResponse"):
"""
_str = self.text

sr_str = 'name="%s" value="' % ver
sr_str = f'name="{ver}" value="'
rs_str = 'name="RelayState" value="'

i = _str.find(sr_str)
Expand Down
8 changes: 3 additions & 5 deletions auth_saml/tests/test_pysaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ def test_ensure_provider_appears_on_login_with_redirect_param(self):
)
self.assertIn("Login with Authentic", response.text)
self.assertIn(
"/auth_saml/get_auth_request?pid={}&redirect=%2Fweb%23action%3D37%26mod"
"el%3Dir.module.module%26view_type%3Dkanban%26menu_id%3D5".format(
self.saml_provider.id
),
f"/auth_saml/get_auth_request?pid={self.saml_provider.id}&redirect=%2Fweb%23action%3D37%26mod"
"el%3Dir.module.module%26view_type%3Dkanban%26menu_id%3D5",
response.text,
)

Expand Down Expand Up @@ -127,7 +125,7 @@ def test__compute_sp_metadata_url__provider_has_sp_baseurl(self):
{"p": self.saml_provider.id, "d": self.env.cr.dbname}
)
expected_url = urllib.parse.urljoin(
"http://example.com", ("/auth_saml/metadata?%s" % expected_qs)
"http://example.com", (f"/auth_saml/metadata?{expected_qs}")
)
# Assert that sp_metadata_url is set correctly
self.assertEqual(self.saml_provider.sp_metadata_url, expected_url)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# generated from manifests external_dependencies
pysaml2
python-jose

0 comments on commit 3a89c8b

Please sign in to comment.