Skip to content

Commit

Permalink
try out golangci/golangci-lint-action
Browse files Browse the repository at this point in the history
  • Loading branch information
ss89 committed Dec 9, 2020
1 parent 90e05b5 commit f0ddec9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 26 deletions.
10 changes: 4 additions & 6 deletions pkg/apiserver/auth/basic_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const (
)

type basicAuthAuthenticator struct {
logger mon.Logger
users map[string]string
users map[string]string
}

func NewBasicAuthHandler(config cfg.Config, logger mon.Logger) gin.HandlerFunc {
Expand Down Expand Up @@ -66,13 +65,12 @@ func NewBasicAuthAuthenticator(config cfg.Config, logger mon.Logger) Authenticat
users[split[0]] = split[1]
}

return NewBasicAuthAuthenticatorWithInterfaces(logger, users)
return NewBasicAuthAuthenticatorWithInterfaces(users)
}

func NewBasicAuthAuthenticatorWithInterfaces(logger mon.Logger, users map[string]string) Authenticator {
func NewBasicAuthAuthenticatorWithInterfaces(users map[string]string) Authenticator {
return &basicAuthAuthenticator{
logger: logger,
users: users,
users: users,
}
}

Expand Down
20 changes: 8 additions & 12 deletions pkg/apiserver/auth/basic_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import (
"encoding/base64"
"fmt"
"github.com/applike/gosoline/pkg/apiserver/auth"
"github.com/applike/gosoline/pkg/mon"
"github.com/applike/gosoline/pkg/mon/mocks"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)

func getBasicAuthMocks(user string, password string) (mon.Logger, *gin.Context) {
logger := mocks.NewLoggerMockedAll()

func getBasicAuthMocks(user string, password string) *gin.Context {
header := http.Header{}
header.Set("Authorization", fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", user, password)))))

Expand All @@ -27,13 +23,13 @@ func getBasicAuthMocks(user string, password string) (mon.Logger, *gin.Context)

ginCtx.Request = request

return logger, ginCtx
return ginCtx
}

func TestBasicAuth_Authenticate_InvalidUser(t *testing.T) {
logger, ginCtx := getBasicAuthMocks("user", "password")
ginCtx := getBasicAuthMocks("user", "password")

a := auth.NewBasicAuthAuthenticatorWithInterfaces(logger, map[string]string{
a := auth.NewBasicAuthAuthenticatorWithInterfaces(map[string]string{
"other user": "other password",
})
_, err := a.IsValid(ginCtx)
Expand All @@ -44,9 +40,9 @@ func TestBasicAuth_Authenticate_InvalidUser(t *testing.T) {
}

func TestBasicAuth_Authenticate_InvalidPassword(t *testing.T) {
logger, ginCtx := getBasicAuthMocks("user", "password")
ginCtx := getBasicAuthMocks("user", "password")

a := auth.NewBasicAuthAuthenticatorWithInterfaces(logger, map[string]string{
a := auth.NewBasicAuthAuthenticatorWithInterfaces(map[string]string{
"user": "other password",
})
_, err := a.IsValid(ginCtx)
Expand All @@ -57,9 +53,9 @@ func TestBasicAuth_Authenticate_InvalidPassword(t *testing.T) {
}

func TestBasicAuth_Authenticate_ValidUser(t *testing.T) {
logger, ginCtx := getBasicAuthMocks("user", "password")
ginCtx := getBasicAuthMocks("user", "password")

a := auth.NewBasicAuthAuthenticatorWithInterfaces(logger, map[string]string{
a := auth.NewBasicAuthAuthenticatorWithInterfaces(map[string]string{
"user": "password",
})
_, err := a.IsValid(ginCtx)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddb/metric_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewMetricRepository(_ cfg.Config, _ mon.Logger, repo Repository) *metricRep
}
}

func (r metricRepository) PutItem(ctx context.Context, qb PutItemBuilder, item interface{}) (*PutItemResult, error) {
func (r metricRepository) PutItem(ctx context.Context, _ PutItemBuilder, item interface{}) (*PutItemResult, error) {
start := time.Time{}
saved, err := r.Repository.PutItem(ctx, nil, item)
r.writeMetric(OpSave, err, start)
Expand Down
8 changes: 4 additions & 4 deletions pkg/refl/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ func TestMapOf(t *testing.T) {

item := m.NewElement().(*Item)
item.Value = "foo"
m.Set(3, item)
_ = m.Set(3, item)

item = m.NewElement().(*Item)
item.Value = "bar"
m.Set(5, item)
_ = m.Set(5, item)

assert.Len(t, items, 2)
assert.Equal(t, "foo", items[3].Value)
Expand All @@ -59,11 +59,11 @@ func TestMapOfPointer(t *testing.T) {

item := m.NewElement().(*Item)
item.Value = "foo"
m.Set(3, item)
_ = m.Set(3, item)

item = m.NewElement().(*Item)
item.Value = "bar"
m.Set(5, item)
_ = m.Set(5, item)

assert.Len(t, items, 2)
assert.Equal(t, "foo", items[3].Value)
Expand Down
3 changes: 1 addition & 2 deletions pkg/sqs/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import (
)

const (
sqsBatchSize = 10
sqsMaxMessageSize = 256 * 1024
sqsBatchSize = 10
)

//go:generate mockery -name Queue
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/env/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewEnvironment(t *testing.T, options ...Option) (*Environment, error) {
var err error
var skeletons []*componentSkeleton
var component Component
var containers = make(map[string]*container)
var containers = map[string]*container{}
var components = NewComponentsContainer()
var componentConfigManger = NewComponentsConfigManager(config)

Expand Down

0 comments on commit f0ddec9

Please sign in to comment.