nixos/keycloak: fixup login test after ui change

This commit is contained in:
Nick Cao 2024-10-04 20:39:33 -04:00
parent 0cdc3e2a0b
commit 05caac302f
No known key found for this signature in database

View File

@ -48,8 +48,7 @@ let
]; ];
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
xmlstarlet htmlq
html-tidy
jq jq
]; ];
}; };
@ -151,16 +150,14 @@ let
# post url. # post url.
keycloak.succeed( keycloak.succeed(
"curl -sSf -c cookie '${frontendUrl}/realms/${realm.realm}/protocol/openid-connect/auth?client_id=${client.name}&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+email&response_type=code&response_mode=query&nonce=qw4o89g3qqm' >login_form", "curl -sSf -c cookie '${frontendUrl}/realms/${realm.realm}/protocol/openid-connect/auth?client_id=${client.name}&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+email&response_type=code&response_mode=query&nonce=qw4o89g3qqm' >login_form",
"tidy -asxml -q -m login_form || true", "htmlq '#kc-form-login' --attribute action --filename login_form --output form_post_url"
"xml sel -T -t -m \"_:html/_:body/_:div/_:div/_:div/_:div/_:div/_:div/_:form[@id='kc-form-login']\" -v @action login_form >form_post_url",
) )
# Post the login form and save the response. Once again tidy up # Post the login form and save the response. Once again tidy up
# the HTML, then extract the authorization code. # the HTML, then extract the authorization code.
keycloak.succeed( keycloak.succeed(
"curl -sSf -L -b cookie -d 'username=${user.username}' -d 'password=${password}' -d 'credentialId=' \"$(<form_post_url)\" >auth_code_html", "curl -sSf -L -b cookie -d 'username=${user.username}' -d 'password=${password}' -d 'credentialId=' \"$(<form_post_url)\" >auth_code_html",
"tidy -asxml -q -m auth_code_html || true", "htmlq '#code' --attribute value --filename auth_code_html --output auth_code"
"xml sel -T -t -m \"_:html/_:body/_:div/_:div/_:div/_:div/_:div/_:input[@id='code']\" -v @value auth_code_html >auth_code",
) )
# Exchange the authorization code for an access token. # Exchange the authorization code for an access token.