Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Start a fake TPP server and run the TPP tests against it #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: test
on:
push:
branches: [master]
pull_request: {}
jobs:
fake-tpp:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- run: make fake_tpp_test
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ test: get linter
go test -v -coverprofile=cov_cmd.out ./cmd/vcert
go tool cover -func=cov_cmd.out

WHAT ?= .

tpp_test: get
go test -v $(GOFLAGS) -coverprofile=cov_tpp.out ./pkg/venafi/tpp
go test -v $(GOFLAGS) -coverprofile=cov_tpp.out ./pkg/venafi/tpp -run $(WHAT)
go tool cover -func=cov_tpp.out

fake_tpp_test: export MAKE := $(MAKE)
fake_tpp_test: export WHAT := ^\(TestPingTPP\|TestRetrieveSelfIdentity\|TestGetRefreshToken\|TestGetRefreshTokenWithDefaultScope\|TestFailRefreshAccessToken\|TestRefreshAccessToken\|TestRefreshAccessTokenNoClientID\|TestAuthenticationAccessToken\)$$
fake_tpp_test:
go test ./test/tpp/fake/... -count=1 -v

cloud_test: get
go test -v $(GOFLAGS) -coverprofile=cov_vaas.out ./pkg/venafi/cloud
go tool cover -func=cov_vaas.out
Expand Down
17 changes: 16 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
module github.com/Venafi/vcert/v4

require (
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-logr/logr v1.2.3
github.com/go-openapi/errors v0.20.3
github.com/go-openapi/strfmt v0.21.3
github.com/go-openapi/swag v0.22.3
github.com/google/uuid v1.1.2
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.20.1
github.com/pavel-v-chernykh/keystore-go/v4 v4.1.0
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.8.0
github.com/urfave/cli/v2 v2.1.1
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
gopkg.in/ini.v1 v1.51.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.25.2
k8s.io/klog/v2 v2.70.1
software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237
)

Expand Down
266 changes: 251 additions & 15 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pkg/venafi/tpp/tpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ type oauthGetRefreshTokenRequest struct {
}
type OauthGetRefreshTokenResponse struct {
Access_token string `json:"access_token,omitempty"`
Expires int `json:"expires,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"` //Attribute added as it's used on vSSH
Expires uint64 `json:"expires,omitempty"`
ExpiresIn uint64 `json:"expires_in,omitempty"` //Attribute added as it's used on vSSH
Identity string `json:"identity,omitempty"`
Refresh_token string `json:"refresh_token,omitempty"`
Refresh_until int `json:"refresh_until,omitempty"`
Refresh_until uint64 `json:"refresh_until,omitempty"`
Scope string `json:"scope,omitempty"`
Token_type string `json:"token_type,omitempty"`
}
Expand All @@ -219,10 +219,10 @@ type oauthCertificateTokenRequest struct {

type OauthRefreshAccessTokenResponse struct {
Access_token string `json:"access_token,omitempty"`
Expires int `json:"expires,omitempty"`
Expires uint64 `json:"expires,omitempty"`
Identity string `json:"identity,omitempty"`
Refresh_token string `json:"refresh_token,omitempty"`
Refresh_until int `json:"refresh_until,omitempty"`
Refresh_until uint64 `json:"refresh_until,omitempty"`
Token_type string `json:"token_type,omitempty"`
}

Expand Down
16 changes: 16 additions & 0 deletions test/tpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Fake TPP Server


```terminal
$ go run ./test/tpp/...
I0930 18:00:58.750488 174501 main.go:15] "started" url="https://127.0.0.1:35103"
```


```terminal
$ vcert getcred --insecure -u https://127.0.0.1:45817 -t foo --verbose --username user1 --password pass1
vCert: 2022/09/30 18:21:24 Getting credentials...
vCert: 2022/09/30 18:21:24 Got 400 Bad Request status for POST https://127.0.0.1:45817/vedauth/authorize/token
vCert: 2022/09/30 18:21:24 unexpected status code on TPP Authorize. Status: 400 Bad Request
```
Loading