forked from Venafi/vcert
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f229297
Showing
123 changed files
with
18,793 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Go/bin/* | ||
Go/pkg/* | ||
Go/src/* | ||
.idea | ||
vCert | ||
/bin/ | ||
aruba/tmp/ | ||
aruba/bin/ | ||
aruba/vcert | ||
vcert.exe | ||
Gemfile.lock | ||
aruba/features/step_definitions/0.endpoints.rb | ||
aruba/log.log | ||
/vars | ||
/exec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM golang:latest | ||
|
||
COPY . /go/src/github.com/Venafi/vcert | ||
|
||
WORKDIR /go/src/github.com/Venafi/vcert | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env groovy | ||
node("jnode-vcert") { | ||
|
||
String goPath = "/go/src/github.com/Venafi/vcert" | ||
|
||
stage('Checkout') { | ||
checkout scm | ||
} | ||
|
||
stage("Build") { | ||
docker.image("golang:1.9").inside("-v ${pwd()}:${goPath} -u root") { | ||
sh "cd ${goPath} && make build" | ||
} | ||
} | ||
|
||
stage("Run Tests") { | ||
parallel( | ||
test: { | ||
docker.image("golang:1.9").inside("-v ${pwd()}:${goPath} -u root") { | ||
sh "cd ${goPath} && go get ./... && make test" | ||
} | ||
}, | ||
e2eTPP: { | ||
docker.image("golang:1.9").inside("-v ${pwd()}:${goPath} -u root") { | ||
sh "cd ${goPath} && go get ./... && make tpp_test" | ||
} | ||
}, | ||
e2eCloud: { | ||
docker.image("golang:1.9").inside("-v ${pwd()}:${goPath} -u root") { | ||
sh "cd ${goPath} && go get ./... && make cloud_test" | ||
} | ||
}, | ||
testCLI: { | ||
sh "make cucumber" | ||
} | ||
) | ||
} | ||
|
||
stage("Deploy") { | ||
archiveArtifacts artifacts: 'bin/**/*', fingerprint: true | ||
} | ||
|
||
stage("Publish") { | ||
cifsPublisher paramPublish: null, masterNodeName:'', alwaysPublishFromMaster: false, | ||
continueOnError: false, | ||
failOnError: false, | ||
publishers: [[ | ||
configName: 'buildsDev', | ||
transfers: [[ | ||
cleanRemote: true, excludes: '*/obj/,/node_modules/,/_src/,/_config/,/_sassdocs/', | ||
flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', | ||
remoteDirectory: env.JOB_NAME, remoteDirectorySDF: false, | ||
removePrefix: 'bin', | ||
sourceFiles: 'bin/' | ||
]], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true | ||
]] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
GOFLAGS ?= $(GOFLAGS:) | ||
|
||
get: gofmt | ||
go get $(GOFLAGS) ./... | ||
|
||
build: get | ||
env GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -o bin/linux/vcert ./cmd/vcert | ||
env GOOS=linux GOARCH=386 go build -ldflags '-s -w' -o bin/linux/vcert86 ./cmd/vcert | ||
env GOOS=darwin GOARCH=amd64 go build -ldflags '-s -w' -o bin/darwin/vcert ./cmd/vcert | ||
env GOOS=darwin GOARCH=386 go build -ldflags '-s -w' -o bin/darwin/vcert86 ./cmd/vcert | ||
env GOOS=windows GOARCH=amd64 go build -ldflags '-s -w' -o bin/windows/vcert.exe ./cmd/vcert | ||
env GOOS=windows GOARCH=386 go build -ldflags '-s -w' -o bin/windows/vcert86.exe ./cmd/vcert | ||
|
||
cucumber: | ||
rm -rf ./aruba/bin/ | ||
mkdir -p ./aruba/bin/ && cp ./bin/linux/vcert ./aruba/bin/vcert | ||
docker build --tag vcert.auto aruba/ | ||
if [ -z "$(FEATURE)" ]; then \ | ||
cd aruba && ./cucumber.sh; \ | ||
else \ | ||
cd aruba && ./cucumber.sh $(FEATURE); \ | ||
fi | ||
|
||
gofmt: | ||
! gofmt -l . | grep -v ^vendor/ | grep . | ||
|
||
test: get | ||
go test -v -cover . | ||
go test -v -cover ./pkg/certificate | ||
go test -v -cover ./pkg/endpoint | ||
go test -v -cover ./pkg/venafi/fake | ||
go test -v -cover ./cmd/vcert/output | ||
go test -v -cover ./cmd/vcert | ||
|
||
tpp_test: get | ||
go test -v $(GOFLAGS) ./pkg/venafi/tpp \ | ||
-tpp-url "${VCERT_TPP_URL}" \ | ||
-tpp-user "${VCERT_TPP_USER}" \ | ||
-tpp-password "${VCERT_TPP_PASSWORD}" \ | ||
-tpp-zone "${VCERT_TPP_ZONE}" | ||
|
||
cloud_test: get | ||
go test -v $(GOFLAGS) ./pkg/venafi/cloud \ | ||
-cloud-url "${VCERT_CLOUD_URL}" \ | ||
-cloud-api-key "${VCERT_CLOUD_APIKEY}" \ | ||
-cloud-zone "${VCERT_CLOUD_ZONE}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# VCert | ||
|
||
<img src="https://www.venafi.com/sites/default/files/content/body/Light_background_logo.png" width="330px" height="69px"/> | ||
|
||
VCert is a Go library, SDK, and command line utility designed to simplify key generation and enrollment of machine identities | ||
(also known as SSL/TLS certificates and keys) that comply with enterprise security policy by using the | ||
[Venafi Platform](https://www.venafi.com/platform/trust-protection-platform) or [Venafi Cloud](https://pki.venafi.com/venafi-cloud/). | ||
|
||
## Installation | ||
|
||
1. Configure your Go environment according to https://golang.org/doc/install. | ||
2. Verify that GOPATH environment variable is set correctly | ||
3. Download the source code: | ||
|
||
```sh | ||
go get github.com/Venafi/vcert | ||
``` | ||
|
||
or | ||
|
||
```sh | ||
git clone https://github.com/Venafi/vcert.git $GOPATH/src/github.com/Venafi/vcert | ||
``` | ||
4. Build the command line utilities for Linux, MacOS, and Windows: | ||
|
||
```sh | ||
make build | ||
``` | ||
|
||
## Usage example | ||
|
||
For code samples of programmatic use, please review the files in [/example](/example). | ||
|
||
1. In your main.go file, make the following import declarations: `github.com/Venafi/vcert`, `github.com/Venafi/vcert/pkg/certificate`, and `github.com/Venafi/vcert/pkg/endpoint`. | ||
2. Create a configuration object of type `&vcert.Config` that specifies the Venafi connection details. Solutions are typically designed to get those details from a secrets vault, .ini file, environment variables, or command line parameters. | ||
3. Instantiate a client by calling the `NewClient` method of the vcert class with the configuration object. | ||
4. Compose a certiticate request object of type `&certificate.Request`. | ||
5. Generate a key pair and CSR for the certificate request by calling the `GenerateRequest` method of the client. | ||
6. Submit the request by passing the certificate request object to the `RequestCertificate` method of the client. | ||
7. Use the request ID to pickup the certificate using the `RetrieveCertificate` method of the client. | ||
|
||
Samples are in a state where you can build/execute them using the following commands (after setting the environment variables discussed later): | ||
|
||
```sh | ||
go build -o cli ./example | ||
go test -v ./example -run TestRequestCertificate | ||
``` | ||
|
||
For command line examples, please see the [Knowledge Base at support.venafi.com](https://support.venafi.com/hc/en-us/articles/217991528-Introducing-VCert-API-Abstraction-for-DevOpsSec). | ||
|
||
## Testing with Trust Protection Platform and Cloud | ||
|
||
Unit tests: | ||
|
||
```sh | ||
make test | ||
``` | ||
|
||
Integration tests for Trust Protection Platform and Cloud products require endpoint connection variables: | ||
|
||
```sh | ||
export VCERT_TPP_URL=https://tpp.venafi.example/vedsdk | ||
export VCERT_TPP_USER=tpp-user | ||
export VCERT_TPP_PASSWORD=tpp-password | ||
export VCERT_TPP_ZONE='some\policy' | ||
|
||
make tpp_test | ||
``` | ||
|
||
```sh | ||
export VCERT_CLOUD_URL=https://api.venafi.cloud/v1 | ||
export VCERT_CLOUD_APIKEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export VCERT_CLOUD_ZONE=Default | ||
|
||
make cloud_test | ||
``` | ||
|
||
Command line utility tests make use of [Cucumber & Aruba](https://github.com/cucumber/aruba) feature files. | ||
|
||
- To run tests for all features in parallel: | ||
|
||
```sh | ||
make cucumber | ||
``` | ||
|
||
- To run tests only for a specific feature (e.g. basic, config, enroll, format, gencsr, renew, or revoke): | ||
|
||
```sh | ||
make cucumber FEATURE=./features/basic/version.feature | ||
``` | ||
|
||
When run, these tests will be executed in their own Docker container using the Ruby version of Cucumber. | ||
The completed test run will report on the number of test "scenarios" and "steps" that passed, failed, or were skipped. | ||
|
||
## Contributing to VCert | ||
|
||
1. Fork it (<https://github.com/yourname/yourproject/fork>) | ||
2. Create your feature branch (`git checkout -b Venafi/vcert`) | ||
3. Commit your changes (`git commit -am 'Added some cool functionality'`) | ||
4. Push to the branch (`git push origin Venafi/vcert`) | ||
5. Create a new Pull Request | ||
|
||
## Release History | ||
|
||
- 3.18.3.1 | ||
- First open source release | ||
|
||
## License | ||
|
||
Copyright © Venafi, Inc. All rights reserved. | ||
|
||
VCert is licensed under the Apache License, Version 2.0. See `LICENSE` for the full license text. | ||
|
||
Please direct questions/comments to [email protected]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM ruby | ||
MAINTAINER Alexander Tarasenko <[email protected]> | ||
|
||
RUN gem install aruba json_spec | ||
COPY . /vcert/ | ||
ENV PATH="/vcert/bin:${PATH}" | ||
|
||
WORKDIR /vcert/ | ||
CMD ["cucumber", "--no-color"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
gem 'aruba', '~> 0.14.6' | ||
gem 'json_spec' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
|
||
=== RubyMine Setup === | ||
|
||
1. building the app every scenario run | ||
|
||
Run -> Edit Configurations... | ||
|
||
Templates -> Cucumber | ||
|
||
Add Before launch: External tool | ||
|
||
Program: /usr/local/go/bin/go | ||
Arguments: build -o bin/vcert ../cmd/vcert | ||
Working directory: $GOPATH/src/github.com/Venafi/vcert/aruba | ||
|
||
OK -> OK -> Apply -> OK | ||
|
||
|
||
2. setting up local variables so that real-run scenarios knocks to real endpoints from IDE: | ||
|
||
$ vi aruba/features/step_definitions/0.endpoints.rb | ||
|
||
ENV['VCERT_TPP_URL'] = "https://tpp.venafi.example.com:5008/vedsdk" | ||
ENV['VCERT_TPP_USER'] = "user" | ||
ENV['VCERT_TPP_PASSWORD'] = "xxx" | ||
ENV['VCERT_TPP_ZONE'] = 'some\zone' | ||
ENV['VCERT_CLOUD_URL'] = "https://api.venafi.example.com/v1" | ||
ENV['VCERT_CLOUD_APIKEY'] = "xxxxxxxx-b256-4c43-a4d4-15372ce2d548" | ||
ENV['VCERT_CLOUD_ZONE'] = "Default" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
RUN_COMMAND="docker run -t --rm \ | ||
-e VCERT_TPP_URL \ | ||
-e VCERT_TPP_USER \ | ||
-e VCERT_TPP_PASSWORD \ | ||
-e VCERT_TPP_ZONE \ | ||
-e VCERT_CLOUD_URL \ | ||
-e VCERT_CLOUD_APIKEY \ | ||
-e VCERT_CLOUD_ZONE vcert.auto cucumber --fail-fast --no-color" | ||
|
||
set -e | ||
|
||
if [ x$1 != x ]; then | ||
echo One-feature run | ||
$RUN_COMMAND $1 | ||
elif which parallel; then | ||
echo Parallel... | ||
FEATURES="" | ||
for F in `find features/ -type f -name '*.feature'`; do | ||
FEATURES="$FEATURES $F" | ||
done | ||
parallel -j 20 $RUN_COMMAND -- $FEATURES | ||
else | ||
echo Sequential... | ||
for F in `find features/ -type f -name '*.feature'`; do | ||
$RUN_COMMAND $F | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Feature: Showing usage text page | ||
|
||
As a user | ||
I want to see usage text | ||
|
||
Background: | ||
And the default aruba exit timeout is 180 seconds | ||
|
||
Scenario: Usage text | ||
When I run `vcert` | ||
Then the output should contain: | ||
""" | ||
For additional help run | ||
""" | ||
|
||
Scenario: Enroll help text | ||
When I run `vcert enroll -h` | ||
Then the output should contain: | ||
""" | ||
Enrollment Usage | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: showing version | ||
|
||
As a user, I want to know version number of the app | ||
|
||
Scenario: where user asks for -version | ||
When I run `vcert -version` | ||
Then the output should contain: | ||
""" | ||
Version: 3.18.3.1 | ||
""" |
Oops, something went wrong.