-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix: dont emit empty strings when reading role #66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest, have you tried running acceptance tests using make acceptance
? Want to know if it works for others outside JFrog dev team.
@@ -283,7 +298,7 @@ make artifactory | |||
|
|||
```sh | |||
export VAULT_ADDR=http://localhost:8200 | |||
export VAULT_token=root | |||
export VAULT_TOKEN=root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
I just tried it, and it didn't go well.. I had "make start" in one window, "make artifactory" and "make setup" were done, but "make acceptance" failed a lot :) [tmcneely@local artifactory-secrets-plugin]$ make acceptance
export VAULT_ACC=true && \
go test -run TestAcceptance -cover -coverprofile=coverage.txt -v -p 1 -timeout 5m ./...
Logging in to Artifactory (http://localhost:8082) as admin ...
Generating artifactory admin access token.
=== RUN TestAcceptanceBackend_PathRotate
2023-04-18T11:06:27.005-0600 [WARN] error making system version request: response=<nil> err="parse "": empty url"
test_utils.go:44: parse "": empty url
--- FAIL: TestAcceptanceBackend_PathRotate (0.00s)
=== RUN TestAcceptanceBackend_PathConfig
=== RUN TestAcceptanceBackend_PathConfig/update
test_utils.go:91:
Error Trace: test_utils.go:91
Error: Expected nil, but got: &logical.Response{Secret:<nil>, Auth:<nil>, Data:map[string]interface {}{"error":"access_token is required"}, Redirect:"", Warnings:[]string(nil), WrapInfo:(*wrapping.ResponseWrapInfo)(nil), Headers:map[string][]string(nil)}
Test: TestAcceptanceBackend_PathConfig/update
=== RUN TestAcceptanceBackend_PathConfig/read
test_utils.go:103:
Error Trace: test_utils.go:103
Error: Should NOT be empty, but was <nil>
Test: TestAcceptanceBackend_PathConfig/read
=== RUN TestAcceptanceBackend_PathConfig/delete
--- FAIL: TestAcceptanceBackend_PathConfig (0.00s)
--- FAIL: TestAcceptanceBackend_PathConfig/update (0.00s)
--- FAIL: TestAcceptanceBackend_PathConfig/read (0.00s)
--- PASS: TestAcceptanceBackend_PathConfig/delete (0.00s)
=== RUN TestAcceptanceBackend_PathRole
=== RUN TestAcceptanceBackend_PathRole/configure_backend
test_utils.go:91:
Error Trace: test_utils.go:91
Error: Expected nil, but got: &logical.Response{Secret:<nil>, Auth:<nil>, Data:map[string]interface {}{"error":"access_token is required"}, Redirect:"", Warnings:[]string(nil), WrapInfo:(*wrapping.ResponseWrapInfo)(nil), Headers:map[string][]string(nil)}
Test: TestAcceptanceBackend_PathRole/configure_backend
=== RUN TestAcceptanceBackend_PathRole/create
test_utils.go:202:
Error Trace: test_utils.go:202
Error: Expected nil, but got: &logical.Response{Secret:<nil>, Auth:<nil>, Data:map[string]interface {}{"error":"backend not configured"}, Redirect:"", Warnings:[]string{"Endpoint replaced the value of these parameters with the values captured from the endpoint's path: [role]"}, WrapInfo:(*wrapping.ResponseWrapInfo)(nil), Headers:map[string][]string(nil)}
Test: TestAcceptanceBackend_PathRole/create
=== RUN TestAcceptanceBackend_PathRole/read
test_utils.go:212:
Error Trace: test_utils.go:212
Error: Expected value not to be nil.
Test: TestAcceptanceBackend_PathRole/read
--- FAIL: TestAcceptanceBackend_PathRole (0.00s)
--- FAIL: TestAcceptanceBackend_PathRole/configure_backend (0.00s)
--- FAIL: TestAcceptanceBackend_PathRole/create (0.00s)
--- FAIL: TestAcceptanceBackend_PathRole/read (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1641e51]
goroutine 26 [running]:
testing.tRunner.func1.2({0x16e2b60, 0x1d06900})
/Users/tmcneely/.asdf/installs/golang/1.20.3/go/src/testing/testing.go:1526 +0x24e
testing.tRunner.func1()
/Users/tmcneely/.asdf/installs/golang/1.20.3/go/src/testing/testing.go:1529 +0x39f
panic({0x16e2b60, 0x1d06900})
/Users/tmcneely/.asdf/installs/golang/1.20.3/go/src/runtime/panic.go:884 +0x213
github.com/jfrog/artifactory-secrets-plugin.(*accTestEnv).ReadPathRole(0xc0002a6d20, 0x10cdc17?)
/Users/tmcneely/Projects/Artifactory/artifactory-secrets-plugin/test_utils.go:215 +0x131
testing.tRunner(0xc00026fd40, 0xc000297170)
/Users/tmcneely/.asdf/installs/golang/1.20.3/go/src/testing/testing.go:1576 +0x10b
created by testing.(*T).Run
/Users/tmcneely/.asdf/installs/golang/1.20.3/go/src/testing/testing.go:1629 +0x3ea
FAIL github.com/jfrog/artifactory-secrets-plugin 0.486s
? github.com/jfrog/artifactory-secrets-plugin/cmd/artifactory [no test files]
FAIL
make: *** [acceptance] Error 1 NOTE: Vault and Artifactory are still running, it was the test that segfaulted. EDIT: This has been fixed, see below. The variables are actually JFROG_URL and ARTIFACTORY_ACCESS_TOKEN (we will change that in a future MR) |
ARTIFACTORY_URL ?= http://localhost:8082 | ||
JFROG_ACCESS_TOKEN ?= $(shell TOKEN_USERNAME=$(TOKEN_USERNAME) ARTIFACTORY_URL=$(ARTIFACTORY_URL) ./scripts/getArtifactoryAdminToken.sh) | ||
export ARTIFACTORY_URL ?= http://localhost:8082 | ||
export JFROG_ACCESS_TOKEN ?= $(shell TOKEN_USERNAME=$(TOKEN_USERNAME) ARTIFACTORY_URL=$(ARTIFACTORY_URL) ./scripts/getArtifactoryAdminToken.sh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 I export them in my shell manually. Hence I didn't run into this problem until it's being run in clean env.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I even tried with them manually exported and got very similar output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests actually are using JFROG_URL
and ARTIFACTORY_ACCESS_TOKEN
. I guess we should update them to use the same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the readme says ARTIFACTORY_URL
and JFROG_ACCESS_TOKEN
:) .. yes, do you want me to add that to this PR or is it already bloated enough? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have separate PR 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[tmcneely@local artifactory-secrets-plugin]$ make acceptance
export VAULT_ACC=true && \
go test -run TestAcceptance -cover -coverprofile=coverage.txt -v -p 1 -timeout 5m ./...
Logging in to Artifactory (http://localhost:8082) as admin ...
Generating artifactory admin access token.
=== RUN TestAcceptanceBackend_PathRotate
2023-04-18T12:26:49.916-0600 [DEBUG] oldToken ID: ddc8d463-0fd1-42d0-b2fe-6a25b514566e
2023-04-18T12:26:49.924-0600 [DEBUG] newTokenID: 2e576145-e34e-41a7-aa48-5d812bfcd28f
--- PASS: TestAcceptanceBackend_PathRotate (2.14s)
=== RUN TestAcceptanceBackend_PathConfig
=== RUN TestAcceptanceBackend_PathConfig/update
=== RUN TestAcceptanceBackend_PathConfig/read
=== RUN TestAcceptanceBackend_PathConfig/delete
--- PASS: TestAcceptanceBackend_PathConfig (0.01s)
--- PASS: TestAcceptanceBackend_PathConfig/update (0.00s)
--- PASS: TestAcceptanceBackend_PathConfig/read (0.01s)
--- PASS: TestAcceptanceBackend_PathConfig/delete (0.00s)
=== RUN TestAcceptanceBackend_PathRole
=== RUN TestAcceptanceBackend_PathRole/configure_backend
=== RUN TestAcceptanceBackend_PathRole/create
=== RUN TestAcceptanceBackend_PathRole/read
=== RUN TestAcceptanceBackend_PathRole/delete
=== RUN TestAcceptanceBackend_PathRole/cleanup_backend
--- PASS: TestAcceptanceBackend_PathRole (0.00s)
--- PASS: TestAcceptanceBackend_PathRole/configure_backend (0.00s)
--- PASS: TestAcceptanceBackend_PathRole/create (0.00s)
--- PASS: TestAcceptanceBackend_PathRole/read (0.00s)
--- PASS: TestAcceptanceBackend_PathRole/delete (0.00s)
--- PASS: TestAcceptanceBackend_PathRole/cleanup_backend (0.00s)
=== RUN TestAcceptanceBackend_PathTokenCreate
=== RUN TestAcceptanceBackend_PathTokenCreate/configure_backend
=== RUN TestAcceptanceBackend_PathTokenCreate/create_role
=== RUN TestAcceptanceBackend_PathTokenCreate/create_token_for_role
=== RUN TestAcceptanceBackend_PathTokenCreate/delete_role
=== RUN TestAcceptanceBackend_PathTokenCreate/cleanup_backend
--- PASS: TestAcceptanceBackend_PathTokenCreate (0.02s)
--- PASS: TestAcceptanceBackend_PathTokenCreate/configure_backend (0.01s)
--- PASS: TestAcceptanceBackend_PathTokenCreate/create_role (0.00s)
--- PASS: TestAcceptanceBackend_PathTokenCreate/create_token_for_role (0.01s)
--- PASS: TestAcceptanceBackend_PathTokenCreate/delete_role (0.00s)
--- PASS: TestAcceptanceBackend_PathTokenCreate/cleanup_backend (0.00s)
PASS
github.com/jfrog/artifactory-secrets-plugin coverage: 62.7% of statements
ok github.com/jfrog/artifactory-secrets-plugin 2.648s coverage: 62.7% of statements
? github.com/jfrog/artifactory-secrets-plugin/cmd/artifactory [no test files]
Now when the role is read, it looks like: