Merge pull request #139 from sartography/feature/support_local_openid_in_cypress_tests

Feature/support local openid in cypress tests
This commit is contained in:
jasquat 2023-02-16 14:39:35 -05:00 committed by GitHub
commit 77d8959a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 24 deletions

View File

@ -101,6 +101,7 @@ jobs:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build # pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK: "true"
- name: get_backend_logs_from_docker_compose - name: get_backend_logs_from_docker_compose
if: failure() if: failure()
working-directory: ./spiffworkflow-backend working-directory: ./spiffworkflow-backend

View File

@ -87,8 +87,12 @@ SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get(
# or otherwise changes a process model. # or otherwise changes a process model.
# If publishing is enabled, the contents of this "staging area" / "scratch pad" / WIP spot will be used # If publishing is enabled, the contents of this "staging area" / "scratch pad" / WIP spot will be used
# as the relevant contents for process model that the user wants to publish. # as the relevant contents for process model that the user wants to publish.
SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH = environ.get("SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH") SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH = environ.get(
SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get("SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL") "SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"
)
SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get(
"SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL"
)
SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE = ( SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE = (
environ.get("SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE", default="false") == "true" environ.get("SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE", default="false") == "true"
) )

View File

@ -14,7 +14,8 @@ SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER = (
== "true" == "true"
) )
SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get(
"SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL",
default="https://github.com/sartography/sample-process-models.git",
) )
SPIFFWORKFLOW_BACKEND_GIT_USERNAME = "sartography-automated-committer" SPIFFWORKFLOW_BACKEND_GIT_USERNAME = "sartography-automated-committer"
SPIFFWORKFLOW_BACKEND_GIT_USER_EMAIL = ( SPIFFWORKFLOW_BACKEND_GIT_USER_EMAIL = (

View File

@ -34,5 +34,6 @@ SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_URL = (
".spiffworkflow.org" ".spiffworkflow.org"
) )
SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get(
"SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL",
default="https://github.com/sartography/sample-process-models.git",
) )

View File

@ -15,16 +15,16 @@
<form id="login" method="post" action="{{ url_for('openid.form_submit') }}"> <form id="login" method="post" action="{{ url_for('openid.form_submit') }}">
<p><b>Important:</b> This login form is for demonstration purposes only. In production systems you should <p><b>Important:</b> This login form is for demonstration purposes only. In production systems you should
be using a real Open ID System.</p> be using a real Open ID System.</p>
<input type="text" class="cds--text-input" name="Uname" id="Uname" placeholder="Username"> <input type="text" class="cds--text-input" name="Uname" id="username" placeholder="Username">
<br><br> <br><br>
<input type="Password" class="cds--text-input" name="Pass" id="Pass" placeholder="Password"> <input type="Password" class="cds--text-input" name="Pass" id="password" placeholder="Password">
<br><br> <br><br>
<input type="hidden" name="state" value="{{state}}"/> <input type="hidden" name="state" value="{{state}}"/>
<input type="hidden" name="response_type" value="{{response_type}}"/> <input type="hidden" name="response_type" value="{{response_type}}"/>
<input type="hidden" name="client_id" value="{{client_id}}"/> <input type="hidden" name="client_id" value="{{client_id}}"/>
<input type="hidden" name="scope" value="{{scope}}"/> <input type="hidden" name="scope" value="{{scope}}"/>
<input type="hidden" name="redirect_uri" value="{{redirect_uri}}"/> <input type="hidden" name="redirect_uri" value="{{redirect_uri}}"/>
<input type="submit" name="log" class="cds--btn cds--btn--primary" value="Log In"> <input type="submit" name="log" class="cds--btn cds--btn--primary" id="spiff-login-button" value="Log In">
<br><br> <br><br>
<!-- should maybe add this stuff in eventually, but this is just for testing. <!-- should maybe add this stuff in eventually, but this is just for testing.
<input type="checkbox" id="check"> <input type="checkbox" id="check">

View File

@ -82,7 +82,9 @@ class GitService:
cls.check_for_basic_configs() cls.check_for_basic_configs()
branch_name_to_use = branch_name branch_name_to_use = branch_name
if branch_name_to_use is None: if branch_name_to_use is None:
branch_name_to_use = current_app.config["SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"] branch_name_to_use = current_app.config[
"SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"
]
repo_path_to_use = repo_path repo_path_to_use = repo_path
if repo_path is None: if repo_path is None:
repo_path_to_use = current_app.config[ repo_path_to_use = current_app.config[
@ -132,15 +134,15 @@ class GitService:
def check_for_publish_configs(cls) -> None: def check_for_publish_configs(cls) -> None:
"""Check_for_configs.""" """Check_for_configs."""
cls.check_for_basic_configs() cls.check_for_basic_configs()
if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH"] is None: if (
current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH"]
is None
):
raise MissingGitConfigsError( raise MissingGitConfigsError(
"Missing config for SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH. " "Missing config for SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH. "
"This is required for publishing process models" "This is required for publishing process models"
) )
if ( if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL"] is None:
current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL"]
is None
):
raise MissingGitConfigsError( raise MissingGitConfigsError(
"Missing config for SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL." "Missing config for SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL."
" This is required for publishing process models" " This is required for publishing process models"
@ -212,8 +214,8 @@ class GitService:
if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"] is None: if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"] is None:
raise MissingGitConfigsError( raise MissingGitConfigsError(
"Missing config for SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH. This is required" "Missing config for SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH. This is"
" for updating the repository as a result of the webhook" " required for updating the repository as a result of the webhook"
) )
ref = webhook["ref"] ref = webhook["ref"]

View File

@ -30,7 +30,7 @@ const cypressConfig = {
videoUploadOnPasses: false, videoUploadOnPasses: false,
chromeWebSecurity: false, chromeWebSecurity: false,
e2e: { e2e: {
baseUrl: 'http://localhost:7001', baseUrl: `http://localhost:${process.env.SPIFFWORKFLOW_FRONTEND_PORT || 7001}`,
setupNodeEvents(on, config) { setupNodeEvents(on, config) {
deleteVideosOnSuccess(on) deleteVideosOnSuccess(on)
require('@cypress/grep/src/plugin')(config); require('@cypress/grep/src/plugin')(config);

View File

@ -33,7 +33,7 @@ describe('process-groups', () => {
cy.contains(newGroupDisplayName).should('not.exist'); cy.contains(newGroupDisplayName).should('not.exist');
// meaning the process group list page is loaded, so we can sign out safely without worrying about ajax requests failing // meaning the process group list page is loaded, so we can sign out safely without worrying about ajax requests failing
cy.get('.tile-process-group-content-container').should('exist'); cy.getBySel('process-groups-loaded').should('exist');
}); });
// process groups no longer has pagination post-tiles // process groups no longer has pagination post-tiles

View File

@ -43,17 +43,27 @@ Cypress.Commands.add('navigateToAdmin', () => {
Cypress.Commands.add('login', (selector, ...args) => { Cypress.Commands.add('login', (selector, ...args) => {
cy.visit('/admin'); cy.visit('/admin');
cy.get('#username').type('ciadmin1'); const username = Cypress.env('SPIFFWORKFLOW_FRONTEND_USERNAME') || 'ciadmin1';
cy.get('#password').type('ciadmin1'); const password = Cypress.env('SPIFFWORKFLOW_FRONTEND_PASSWORD') || 'ciadmin1';
cy.get('#kc-login').click(); cy.get('#username').type(username);
cy.get('#password').type(password);
if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) {
cy.get('#kc-login').click();
} else {
cy.get('#spiff-login-button').click();
}
}); });
Cypress.Commands.add('logout', (selector, ...args) => { Cypress.Commands.add('logout', (selector, ...args) => {
cy.getBySel('logout-button').click(); cy.getBySel('logout-button').click();
// otherwise we can click logout, quickly load the next page, and the javascript if (Cypress.env('SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK') === true) {
// doesn't have time to actually sign you out // otherwise we can click logout, quickly load the next page, and the javascript
cy.contains('Sign in to your account'); // doesn't have time to actually sign you out
cy.contains('Sign in to your account');
} else {
cy.get('#spiff-login-button').should('exist');
}
}); });
Cypress.Commands.add('createGroup', (groupId, groupDisplayName) => { Cypress.Commands.add('createGroup', (groupId, groupDisplayName) => {

View File

@ -94,7 +94,13 @@ export default function ProcessGroupListTiles({
}; };
if (processGroups) { if (processGroups) {
return <>{processGroupArea()}</>; return (
<>
{/* so we can check if the groups have loaded in cypress tests */}
<div data-qa="process-groups-loaded" hidden />
{processGroupArea()}
</>
);
} }
return null; return null;
} }