diff --git a/Makefile b/Makefile index 02d218f5..301ebaf5 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ lint: @if [ "z${ARCH}" = "zx86_64" ] && which golangci-lint >/dev/null ; then golangci-lint run --config .golangci.yml ; else echo "WARNING: Linting skipped (not on x86_64 or linter not installed)"; fi install-lint: - sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.51.2 + sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.54.2 test: unittest lint $(GO) vet ./... diff --git a/bootstrap/handlers/messaging_test.go b/bootstrap/handlers/messaging_test.go index a36b8d57..82fc416c 100644 --- a/bootstrap/handlers/messaging_test.go +++ b/bootstrap/handlers/messaging_test.go @@ -67,15 +67,15 @@ func TestBootstrapHandler(t *testing.T) { tests := []struct { Name string - MessageBus config.MessageBusInfo + MessageBus *config.MessageBusInfo Secure bool ExpectedResult bool ExpectClient bool }{ - {"Valid secure - creates client", validCreateClientSecure, true, true, true}, - {"Valid non-secure - creates client", validCreateClientNonSecure, false, true, true}, - {"Invalid - secrets error", invalidSecrets, false, false, false}, - {"Invalid - can't connect", invalidNoConnect, true, false, false}, + {"Valid secure - creates client", &validCreateClientSecure, true, true, true}, + {"Valid non-secure - creates client", &validCreateClientNonSecure, false, true, true}, + {"Invalid - secrets error", &invalidSecrets, false, false, false}, + {"Invalid - can't connect", &invalidNoConnect, true, false, false}, } for _, test := range tests { @@ -84,7 +84,7 @@ func TestBootstrapHandler(t *testing.T) { providerMock.On("GetSecret", test.MessageBus.SecretName).Return(usernameSecretData, nil) configMock := &mocks.Configuration{} configMock.On("GetBootstrap").Return(config.BootstrapConfiguration{ - MessageBus: &test.MessageBus, + MessageBus: test.MessageBus, }) dic.Update(di.ServiceConstructorMap{ diff --git a/bootstrap/messaging/messaging_test.go b/bootstrap/messaging/messaging_test.go index 1888aea3..6db6aaac 100644 --- a/bootstrap/messaging/messaging_test.go +++ b/bootstrap/messaging/messaging_test.go @@ -87,43 +87,43 @@ func TestValidateSecrets(t *testing.T) { Name string SecureMode bool AuthMode string - SecretData SecretData + SecretData *SecretData ErrorExpectation bool ErrorMessage string }{ - {"Invalid AuthMode", true, "BadAuthMode", SecretData{}, true, "Invalid AuthMode of 'BadAuthMode' selected"}, - {"No Auth No error", true, AuthModeNone, SecretData{}, false, ""}, - {"UsernamePassword No Error", true, AuthModeUsernamePassword, SecretData{ + {"Invalid AuthMode", true, "BadAuthMode", &SecretData{}, true, "Invalid AuthMode of 'BadAuthMode' selected"}, + {"No Auth No error", true, AuthModeNone, &SecretData{}, false, ""}, + {"UsernamePassword No Error", true, AuthModeUsernamePassword, &SecretData{ Username: "user", Password: "Password", }, false, ""}, - {"UsernamePassword Error no Username", true, AuthModeUsernamePassword, SecretData{ + {"UsernamePassword Error no Username", true, AuthModeUsernamePassword, &SecretData{ Password: "Password", }, true, "AuthModeUsernamePassword selected however Username or Password was not found for secret=unit-test"}, - {"UsernamePassword blank - non-secure", false, AuthModeUsernamePassword, SecretData{ + {"UsernamePassword blank - non-secure", false, AuthModeUsernamePassword, &SecretData{ Username: "", Password: "", }, false, ""}, - {"UsernamePassword Error no Password", true, AuthModeUsernamePassword, SecretData{ + {"UsernamePassword Error no Password", true, AuthModeUsernamePassword, &SecretData{ Username: "user", }, true, "AuthModeUsernamePassword selected however Username or Password was not found for secret=unit-test"}, - {"ClientCert No Error", true, AuthModeCert, SecretData{ + {"ClientCert No Error", true, AuthModeCert, &SecretData{ CertPemBlock: []byte("----"), KeyPemBlock: []byte("----"), }, false, ""}, - {"ClientCert No Key", true, AuthModeCert, SecretData{ + {"ClientCert No Key", true, AuthModeCert, &SecretData{ CertPemBlock: []byte("----"), }, true, "AuthModeCert selected however the key or cert PEM block was not found for secret=unit-test"}, - {"ClientCert No Cert", true, AuthModeCert, SecretData{ + {"ClientCert No Cert", true, AuthModeCert, &SecretData{ KeyPemBlock: []byte("----"), }, true, "AuthModeCert selected however the key or cert PEM block was not found for secret=unit-test"}, - {"CACert no error", true, AuthModeCA, SecretData{ + {"CACert no error", true, AuthModeCA, &SecretData{ CaPemBlock: []byte(testCACert), }, false, ""}, - {"CACert invalid error", true, AuthModeCA, SecretData{ + {"CACert invalid error", true, AuthModeCA, &SecretData{ CaPemBlock: []byte(`------`), }, true, "Error parsing CA Certificate"}, - {"CACert no ca error", true, AuthModeCA, SecretData{}, true, "AuthModeCA selected however no PEM Block was found for secret=unit-test"}, + {"CACert no ca error", true, AuthModeCA, &SecretData{}, true, "AuthModeCA selected however no PEM Block was found for secret=unit-test"}, } for _, test := range tests { @@ -133,7 +133,7 @@ func TestValidateSecrets(t *testing.T) { defer func() { _ = os.Setenv(secret.EnvSecretStore, "false") }() } - result := ValidateSecretData(test.AuthMode, "unit-test", &test.SecretData) + result := ValidateSecretData(test.AuthMode, "unit-test", test.SecretData) if test.ErrorExpectation { require.Error(t, result, "Result should be an error") assert.Equal(t, test.ErrorMessage, result.Error()) diff --git a/go.mod b/go.mod index 3b60a280..a9b5ac04 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/edgexfoundry/go-mod-bootstrap/v3 -go 1.20 +go 1.21 require ( github.com/eclipse/paho.mqtt.golang v1.4.3