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

build: Upgrade to go 1.21 and linter 1.54.2 #599

Merged
merged 1 commit into from
Sep 12, 2023
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand Down
12 changes: 6 additions & 6 deletions bootstrap/handlers/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand Down
28 changes: 14 additions & 14 deletions bootstrap/messaging/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down