conjurdemos / conjur-intro

Miscellaneous utilities that make it easier to make, manage, and run demos
Apache License 2.0
10 stars 11 forks source link

Add jenkins conjur plugin test #61

Open h-artzi opened 4 years ago

h-artzi commented 4 years ago

Is your feature request related to a problem? Please describe.

I would like to see automated tests for the Jenkins conjur plugin because it will ensure that as the appliance is upgraded, the plugin continues to work.

Describe the solution you would like

  1. Container running DAP
  2. A container running Jenkins. Jenkins should run a job which gets a secret

Describe alternatives you have considered

N/A

Steps taken to test manually

1. Reference jenkins_plugin branch

2. Upload policies to DAP

$ ./cli conjur policy load --replace root policy/users.yml
$ ./cli conjur policy load root policy/policy.yml
$ ./cli conjur policy load staging policy/apps/myapp.yml
$ ./cli conjur policy load production policy/apps/myapp.yml
$ ./cli conjur policy load root policy/application_grants.yml
$ ./cli conjur policy load root policy/hosts.yml

Save the api_key from

➜  jenkins_plugin_test git:(jenkins_plugin) ✗ ./cli conjur policy load root policy/hosts.yml
Logged in
Loaded policy 'root'
{
  "created_roles": {
    "demo:host:test-host-1": {
      "id": "demo:host:test-host-1",
      "api_key": <api_key>
    }
  },
  "version": 4
}

Setting a Variable

./cli conjur variable values add production/myapp/database/username my-username

3. Download the plugin from jenkin-conjur-plugin

OR

git clone {repo}
cd conjur-credentials-plugin
mvn install -DskipTests

This must be uploaded into the Jenkins container:

Option 1:

Option 2:

Restart Jenkins by going to http://localhost:8080/restart and press yes

4. Enter the Jenkins container and download the SSL certificates from DAP

Note: The next steps must be executed by root in the Jenkins container. One way to log in to the Jenkins container as root is by executing docker exec --user 0 -it <docker_id> /bin/bash from your host

5. Setup Jenkins

Screen Shot 2020-04-29 at 5 58 53 PM

6. Create a Freestyle job

7. Run the job and go to Console Output

Screen Shot 2020-04-29 at 6 21 08 PM

izgeri commented 4 years ago

do we already have integration tests like this in this project? I would not have known to look here when trying to understand integration test coverage, and I'm not sure @andytinkham would either.

is there a better place for these kinds of e2e tests to live? we're running into similar questions for k8s e2e tests too - in that case, we've decided a demo repo is definitely not the place for these tests, but we haven't decided on next steps yet.

h-artzi commented 4 years ago

We currently do not have integration tests like this in dap-intro. When I talked to Jason we decided it would be best to assign these tickets to dap-intro (in the meantime). However, we did not discuss where the tests would end up.

izgeri commented 4 years ago

It's worth noting also that the Jenkins plugin is in the process of migrating to be an official Jenkins plugin here: https://github.com/jenkinsci/conjur-credentials-plugin

In addition: