getsops / sops

Simple and flexible tool for managing secrets
https://getsops.io/
Mozilla Public License 2.0
15.77k stars 842 forks source link

Errors with make test #774

Open ursuad opened 3 years ago

ursuad commented 3 years ago

Hi, when I run make test some of the tests are failing because of an issue with the PGP key, and if I comment that out I get a different error, for another test. Any idea why this is happening?

The Go version I use is go version go1.15.5 darwin/amd64

$ make test
GO15VENDOREXPERIMENT=1 GO111MODULE=on GOPROXY=https://proxy.golang.org go mod tidy
GO15VENDOREXPERIMENT=1 GO111MODULE=on GOPROXY=https://proxy.golang.org go mod vendor
gpg --import pgp/sops_functional_tests_key.asc 2>&1 1>/dev/null || exit 0
gpg: key 3D16CEE4A27381B4: "SOPS Functional Tests Key 1 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key 3D16CEE4A27381B4: secret key imported
gpg: key D8720D957C3D3074: "SOPS Functional Tests Key 2 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key D8720D957C3D3074: secret key imported
gpg: key 3D16CEE4A27381B4: "SOPS Functional Tests Key 1 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key D8720D957C3D3074: "SOPS Functional Tests Key 2 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key 19F9B5DAEA91FF86: "SOPS Functional Tests Key 3 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: Total number processed: 5
gpg:              unchanged: 5
gpg:       secret keys read: 2
gpg:  secret keys unchanged: 2
./test.sh
ok      go.mozilla.org/sops/v3  0.372s  coverage: 51.7% of statements
ok      go.mozilla.org/sops/v3/aes      0.390s  coverage: 76.9% of statements
?       go.mozilla.org/sops/v3/audit    [no test files]
ok      go.mozilla.org/sops/v3/azkv     0.171s  coverage: 25.5% of statements
?       go.mozilla.org/sops/v3/cmd/sops [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/codes   [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/common  [no test files]
ok      go.mozilla.org/sops/v3/cmd/sops/formats 0.186s  coverage: 100.0% of statements
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/exec [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/groups       [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/keyservice   [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/publish      [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/updatekeys   [no test files]
ok      go.mozilla.org/sops/v3/config   0.433s  coverage: 77.8% of statements
ok      go.mozilla.org/sops/v3/decrypt  0.316s  coverage: 0.0% of statements [no tests to run]
ok      go.mozilla.org/sops/v3/gcpkms   0.225s  coverage: 25.4% of statements
ok      go.mozilla.org/sops/v3/hcvault  6.153s  coverage: 59.4% of statements
?       go.mozilla.org/sops/v3/keys     [no test files]
ok      go.mozilla.org/sops/v3/keyservice       0.230s  coverage: 5.0% of statements
ok      go.mozilla.org/sops/v3/kms      0.241s  coverage: 57.0% of statements
?       go.mozilla.org/sops/v3/kms/mocks        [no test files]
?       go.mozilla.org/sops/v3/logging  [no test files]
[PGP]    time="2020-11-24T17:01:04Z" level=warning msg="Deprecation Warning: GPG key fetching from a keyserver witihin sops will be removed in a future version of sops. See https://github.com/mozilla/sops/issues/727 for more information."
--- FAIL: TestRetrievePGPKey (0.32s)
    keysource_test.go:49: 
                Error Trace:    keysource_test.go:49
                Error:          Received unexpected error:
                                could not read entities: openpgp: invalid data: entity without any identities
                Test:           TestRetrievePGPKey
FAIL
coverage: 51.1% of statements
FAIL    go.mozilla.org/sops/v3/pgp      32.192s
FAIL
make: *** [test] Error 1

When I configure to skip that test (with t.Skip), I get a different error in another test:

$ make test
GO15VENDOREXPERIMENT=1 GO111MODULE=on GOPROXY=https://proxy.golang.org go mod tidy
GO15VENDOREXPERIMENT=1 GO111MODULE=on GOPROXY=https://proxy.golang.org go mod vendor
gpg --import pgp/sops_functional_tests_key.asc 2>&1 1>/dev/null || exit 0
gpg: key 3D16CEE4A27381B4: "SOPS Functional Tests Key 1 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key 3D16CEE4A27381B4: secret key imported
gpg: key D8720D957C3D3074: "SOPS Functional Tests Key 2 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key D8720D957C3D3074: secret key imported
gpg: key 3D16CEE4A27381B4: "SOPS Functional Tests Key 1 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key D8720D957C3D3074: "SOPS Functional Tests Key 2 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: key 19F9B5DAEA91FF86: "SOPS Functional Tests Key 3 (https://github.com/mozilla/sops/) <secops@mozilla.com>" not changed
gpg: Total number processed: 5
gpg:              unchanged: 5
gpg:       secret keys read: 2
gpg:  secret keys unchanged: 2
./test.sh
ok      go.mozilla.org/sops/v3  0.481s  coverage: 51.7% of statements
ok      go.mozilla.org/sops/v3/aes  0.459s  coverage: 76.9% of statements
?       go.mozilla.org/sops/v3/audit    [no test files]
ok      go.mozilla.org/sops/v3/azkv 0.219s  coverage: 25.5% of statements
?       go.mozilla.org/sops/v3/cmd/sops [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/codes   [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/common  [no test files]
ok      go.mozilla.org/sops/v3/cmd/sops/formats 0.230s  coverage: 100.0% of statements
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/exec [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/groups   [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/keyservice   [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/publish  [no test files]
?       go.mozilla.org/sops/v3/cmd/sops/subcommand/updatekeys   [no test files]
ok      go.mozilla.org/sops/v3/config   0.348s  coverage: 77.8% of statements
ok      go.mozilla.org/sops/v3/decrypt  0.337s  coverage: 0.0% of statements [no tests to run]
ok      go.mozilla.org/sops/v3/gcpkms   0.243s  coverage: 25.4% of statements
ok      go.mozilla.org/sops/v3/hcvault  8.183s  coverage: 59.4% of statements
?       go.mozilla.org/sops/v3/keys [no test files]
ok      go.mozilla.org/sops/v3/keyservice   0.278s  coverage: 5.0% of statements
ok      go.mozilla.org/sops/v3/kms  0.278s  coverage: 57.0% of statements
?       go.mozilla.org/sops/v3/kms/mocks    [no test files]
?       go.mozilla.org/sops/v3/logging  [no test files]
ok      go.mozilla.org/sops/v3/pgp  32.935s coverage: 46.0% of statements
?       go.mozilla.org/sops/v3/publish  [no test files]
ok      go.mozilla.org/sops/v3/shamir   0.222s  coverage: 96.2% of statements
ok      go.mozilla.org/sops/v3/stores   0.366s  coverage: 38.7% of statements
ok      go.mozilla.org/sops/v3/stores/dotenv    0.282s  coverage: 31.4% of statements
# go.mozilla.org/sops/v3/stores/ini
stores/ini/store.go:292: conversion from int64 to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
FAIL    go.mozilla.org/sops/v3/stores/ini [build failed]
FAIL
make: *** [test] Error 2
felixfontein commented 3 years ago

I'm also getting that test failure:

# go.mozilla.org/sops/v3/stores/ini
stores/ini/store.go:292:21: conversion from int64 to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)

The lines in question:

    case reflect.Int:
        if field.Int() != 0 {
            result[prefix] = string(field.Int())
        }

I would guess that this is wrong (https://golangdocs.com/converting-integer-to-string-in-golang), since I would assume that in this case, the integer should be converted into a string. On the other hand, it is impossible to verify that, since the function encodeMetadataItem containing this code is not used anywhere. I think I'll create a PR to simply remove it :-)

mitar commented 2 years ago

This is fixed in develop branch.