Skip to content

Commit

Permalink
Create LDAP CI test (#116)
Browse files Browse the repository at this point in the history
* Create ldap.yml
* Create a continuous integration pipeline for CWS using LDAP security and associated tests.
* Test security env variable.
* Configure open source LDAP for CI.
* Adjust wait time for web elements
* Create WebTestLdap
* Publish CWS Docker image
* Adjust WebTestUtil for timeout error
* Run WebTestLdap
* Update WebTestUtil
* Update workflow files
* Update web elements for integration tests
  • Loading branch information
RonnyFrayRegato authored Sep 8, 2022
1 parent 3b33764 commit 8c87cfa
Show file tree
Hide file tree
Showing 16 changed files with 279 additions and 54 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/ldap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: CWS CI LDAP

# Triggers the workflow on push
on:
push:
schedule:
# trigger a build and test of CWS daily at 5 AM PST / 12 PM UTC
- cron: '0 12 * * *'

jobs:

build-and-test-cws:

runs-on: ubuntu-latest
env:
SECURITY: "LDAP"

steps:
- uses: actions/checkout@v3

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven

- name: Create open-source certs
run: |
cd cws-certs
chmod +x generate-certs.sh
./generate-certs.sh
- name: Download Logstash
uses: carlosperate/download-file-action@v1
with:
file-url: https://artifacts.elastic.co/downloads/logstash/logstash-oss-7.16.2-windows-x86_64.zip
file-name: logstash-7.16.2.zip
location: install/logging/

- name: Check for Logstash
run: |
cd install/logging/
ls -l
- name: Set up Elasticsearch
run: |
cd install/docker/es-only
docker-compose up -d
- name: Set up CWS database using Docker
run: docker run -d -p 3306:3306 -e MYSQL_DATABASE=cws_dev -e MYSQL_ROOT_PASSWORD=adminpw --name mdb103 mariadb:10.3

- name: Set up CWS LDAP Server
run: |
cd cws-opensource-ldap
docker-compose up -d
- name: Show Docker containers
run: |
sleep 5s
docker ps -a
- name: Build CWS
id: build
run: |
cd ci
chmod +x run_ci.sh
./run_ci.sh $SECURITY
shell: bash

- name: Show CWS Log
run: |
cd dist/console-only/cws/server/apache-tomcat-9.0.33/logs
ls -al
- name: Set up Google Chrome
run: |
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable
- name: Display Google Chrome version
run: google-chrome --version

- name: Run LDAP Integration Tests
id: ldap
run: mvn -DfailIfNoTests=false -Dtest=WebTestLdap clean test
shell: bash

- name: Send custom JSON data to Slack workflow
if: ${{ always() }}
id: slack
uses: slackapi/[email protected]
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"status": "CWS CI LDAP build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nLDAP integration test result: ${{ steps.ldap.outcome }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "CWS CI LDAP build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nLDAP integration test result: ${{ steps.ldap.outcome }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
76 changes: 68 additions & 8 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CWS CI
name: CWS CI Camunda

# Triggers the workflow on push
on:
Expand All @@ -9,71 +9,96 @@ on:

jobs:

build-cws:
build-and-test-cws:

runs-on: ubuntu-latest
env:
SECURITY: "CAMUNDA"

steps:
- uses: actions/checkout@v3

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven

- name: Create open-source certs
run: |
cd cws-certs
chmod +x generate-certs.sh
./generate-certs.sh
- name: Download Logstash
uses: carlosperate/download-file-action@v1
with:
file-url: https://artifacts.elastic.co/downloads/logstash/logstash-oss-7.16.2-windows-x86_64.zip
file-name: logstash-7.16.2.zip
location: install/logging/

- name: Check for Logstash
run: |
cd install/logging/
ls -l
- name: Set up Elasticsearch
run: |
cd install/docker/es-only
docker-compose up -d
- name: Set up CWS database using Docker
run: docker run -d -p 3306:3306 -e MYSQL_DATABASE=cws_dev -e MYSQL_ROOT_PASSWORD=adminpw --name mdb103 mariadb:10.3

- name: Show Docker containers
run: |
sleep 5s
docker ps -a
- name: Run CWS
- name: Build CWS
id: build
run: |
cd ci
chmod +x run_ci.sh
./run_ci.sh
./run_ci.sh $SECURITY
shell: bash

- name: Show CWS Log
run: |
cd dist/console-only/cws/server/apache-tomcat-9.0.33/logs
ls -al
- uses: browser-actions/setup-chrome@latest
- run: chrome --version
- name: Set up Google Chrome
run: |
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable
- name: Display Google Chrome version
run: google-chrome --version

- name: Run Unit Tests
id: unit
run: mvn -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source clean test jacoco:report-aggregate
shell: bash

- name: Run Integration Tests
id: integration
run: mvn -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source integration-test verify -DskipTests
shell: bash

- name: Upload Jacoco report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: jacoco-reports/aggregate/index.html

- name: Upload test screenshots
uses: actions/upload-artifact@v3
with:
name: test-screenshots
path: test-screenshots/

- name: Send custom JSON data to Slack workflow
if: ${{ always() }}
id: slack
Expand All @@ -82,16 +107,51 @@ jobs:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"status": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"status": "CWS CI Camunda build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nUnit test result: ${{ steps.unit.outcome }}\nIntegration test result: ${{ steps.integration.outcome }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
"text": "CWS CI Camunda build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nUnit test result: ${{ steps.unit.outcome }}\nIntegration test result: ${{ steps.integration.outcome }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


publish-cws-image:

if: contains(github.event.head_commit.message, 'version')
needs: build-and-test-cws
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Generate CWS Docker image
run: |
cd install/docker/cws-image
./build.sh
- name: Re-Tag CWS Docker image for open source
run: docker tag nasa-ammos/common-workflow-service:${{ github.ref_name }} ${{ secrets.DOCKER_USERNAME }}/common-workflow-service:${{ github.ref_name }}

- name: Push CWS Docker image
run: docker push ${{ secrets.DOCKER_USERNAME }}/common-workflow-service:${{ github.ref_name }}
12 changes: 6 additions & 6 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ source ${ROOT}/../utils.sh

cat > ci_console.conf.template <<- EOF
cam_server_url=NA
cws_ldap_url_default=ldaps://localhost:636
cws_ldap_url_default=ldap://localhost:389
cam_ldap_identity_plugin_class=jpl.cws.core.identity.cam.CamLdapIdentityProviderPlugin
cam_ldap_security_filter_class=jpl.cws.core.web.CwsCamSecurityFilter
ldap_identity_plugin_class=org.camunda.bpm.identity.impl.ldap.plugin.LdapIdentityProviderPlugin
Expand Down Expand Up @@ -81,8 +81,8 @@ elasticsearch_username=${ES_USERNAME}
elasticsearch_password=${ES_PASSWORD}
smtp_hostname=smtp.localhost
default_smtp_hostname=smtp.localhost
default_cws_ldap_url=ldaps://localhost:636
cws_ldap_url=ldaps://localhost:636
default_cws_ldap_url=ldap://localhost:389
cws_ldap_url=ldap://localhost:389
default_elasticsearch_use_auth=n
aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
default_elasticsearch_port=9200
Expand All @@ -98,7 +98,7 @@ EOF

cat > ci_worker.conf.template <<- EOF
cam_server_url=NA
cws_ldap_url_default=ldaps://localhost:636
cws_ldap_url_default=ldap://localhost:389
cam_ldap_identity_plugin_class=jpl.cws.core.identity.cam.CamLdapIdentityProviderPlugin
cam_ldap_security_filter_class=jpl.cws.core.web.CwsCamSecurityFilter
ldap_identity_plugin_class=org.camunda.bpm.identity.impl.ldap.plugin.LdapIdentityProviderPlugin
Expand Down Expand Up @@ -142,8 +142,8 @@ elasticsearch_username=${ES_USERNAME}
elasticsearch_password=${ES_PASSWORD}
smtp_hostname=smtp.localhost
default_smtp_hostname=smtp.localhost
default_cws_ldap_url=ldaps://localhost:636
cws_ldap_url=ldaps://localhost:636
default_cws_ldap_url=ldap://localhost:389
cws_ldap_url=ldap://localhost:389
project_webapp_root=
default_elasticsearch_use_auth=n
aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
Expand Down
2 changes: 1 addition & 1 deletion ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ printf "\nHostname set to '%s'\n\n" $HOSTNAME
# Used in cws-test
echo "$HOSTNAME" > ../cws-test/src/test/resources/hostname.txt

SECURITY="CAMUNDA"
SECURITY=${1} # parameter is passed as an env through workflow file

# Stop CWS is it is currently running
#./stop_dev.sh
Expand Down
12 changes: 6 additions & 6 deletions cws-opensource-ldap/user.ldif
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ dn: ou=Users,dc=example,dc=com
objectClass: organizationalUnit
ou: Users

dn: cn=cwsuser,ou=Users,dc=example,dc=com
dn: cn=cwsci,ou=Users,dc=example,dc=com
objectclass: inetOrgPerson
cn: cwsuser
givenName: cws
sn: user
uid: cwsuser
userpassword: ldapcwspassword
cn: cwsci
givenName: Ronny
sn: Fray
uid: cwsci
userpassword: changeme
mail: [email protected]
12 changes: 6 additions & 6 deletions cws-test/src/test/java/jpl/cws/test/WebTestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void runDeployTest() {
// Start Instance
WebElement tasks = driver.findElement(By.xpath("//a[@href='/camunda/app/tasklist']"));
tasks.click();
findOnPage("<title>Camunda Tasklist</title>");
findOnPage("Camunda Tasklist");

sleep(10000);

Expand All @@ -118,7 +118,7 @@ public void runDeployTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Deployments</title>");
findOnPage("CWS - Deployments");


// Wait for Finish
Expand Down Expand Up @@ -163,7 +163,7 @@ public void runErrorHandlingTest() {
// Start Instance (1) through Camunda
WebElement tasks = driver.findElement(By.xpath("//a[@href='/camunda/app/tasklist']"));
tasks.click();
findOnPage("<title>Camunda Tasklist</title>");
findOnPage("Camunda Tasklist");

sleep(10000);

Expand All @@ -187,7 +187,7 @@ public void runErrorHandlingTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Deployments</title>");
findOnPage("CWS - Deployments");

// Wait for Finish
sleep(180000);
Expand Down Expand Up @@ -228,7 +228,7 @@ public void runHelloWorldTest() {

WebElement tasks = driver.findElement(By.xpath("//a[@href='/camunda/app/tasklist']"));
tasks.click();
findOnPage("<title>Camunda Tasklist</title>");
findOnPage("Camunda Tasklist");

sleep(10000);

Expand All @@ -252,7 +252,7 @@ public void runHelloWorldTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Deployments</title>");
findOnPage("CWS - Deployments");

// Wait for Finish
sleep(90000);
Expand Down
Loading

0 comments on commit 8c87cfa

Please sign in to comment.