Skip to content

Commit

Permalink
feat: more linter
Browse files Browse the repository at this point in the history
  • Loading branch information
skynet2 committed Sep 11, 2024
1 parent 213a80e commit 21028de
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 155 deletions.
7 changes: 1 addition & 6 deletions cmd/vc-rest/startcmd/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"net/http"
"net/http/httptest"
"os"
"reflect"
"testing"
"time"

Expand All @@ -25,8 +24,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/trustbloc/logutil-go/pkg/log"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
nooptracer "go.opentelemetry.io/otel/trace/noop"
Expand Down Expand Up @@ -708,9 +705,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
7 changes: 1 addition & 6 deletions component/oidc/fosite/mongo/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ package mongo
import (
"context"
"fmt"
"reflect"
"testing"
"time"

"github.com/cenkalti/backoff/v4"
dctest "github.com/ory/dockertest/v3"
dc "github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
Expand Down Expand Up @@ -56,9 +53,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
7 changes: 1 addition & 6 deletions component/oidc/fosite/redis/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package redis
import (
"context"
"fmt"
"reflect"
"testing"
"time"

Expand All @@ -19,8 +18,6 @@ import (
redisapi "github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -114,9 +111,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
7 changes: 1 addition & 6 deletions pkg/kms/arieskms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"encoding/base64"
"net/http"
"os"
"reflect"
"testing"
"time"

Expand All @@ -22,8 +21,6 @@ import (
dc "github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"
arieskms "github.com/trustbloc/kms-go/spi/kms"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -237,9 +234,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
7 changes: 1 addition & 6 deletions pkg/ld/store_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package ld_test

import (
"context"
"reflect"
"testing"
"time"

Expand All @@ -17,8 +16,6 @@ import (
dctest "github.com/ory/dockertest/v3"
dc "github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -86,9 +83,7 @@ func waitForMongoDBToBeUp(connectionString string) error {
func pingMongoDB(connectionString string) error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(connectionString)
clientOpts := options.Client().ApplyURI(connectionString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func TestResultWriter_Write(t *testing.T) {

err := writer.Write(&health.CheckerResult{
Status: health.StatusUp,
Details: &map[string]health.CheckResult{
Details: map[string]health.CheckResult{
"up": {
Status: health.StatusUp,
Timestamp: &now,
Timestamp: now,
},
"down": {
Status: health.StatusDown,
Timestamp: &now,
Timestamp: now,
},
},
}, http.StatusOK, rw, nil)
Expand Down
7 changes: 1 addition & 6 deletions pkg/observability/health/mongo/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ package mongo_test

import (
"context"
"reflect"
"testing"
"time"

"github.com/cenkalti/backoff/v4"
dctest "github.com/ory/dockertest/v3"
dc "github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -82,9 +79,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
34 changes: 12 additions & 22 deletions pkg/restapi/v1/oidc4ci/controller_e2e_flows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,13 @@ func testAuthorizeCodeGrantFlow(t *testing.T, proofType string) {

config := new(fosite.Config)
config.EnforcePKCE = true
config.GlobalSecret = []byte("secret-for-signing-and-verifying-signatures")
config.AuthorizeCodeLifespan = time.Minute
config.AccessTokenLifespan = time.Hour

var hmacStrategy = &fositeoauth.HMACSHAStrategy{
Enigma: &hmac.HMACStrategy{
Config: &fosite.Config{
GlobalSecret: []byte("secret-for-signing-and-verifying-signatures"),
},
},
Config: &fosite.Config{
AuthorizeCodeLifespan: time.Minute,
AccessTokenLifespan: time.Hour,
},
}
var hmacStrategy = fositeoauth.NewHMACSHAStrategy(&hmac.HMACStrategy{
Config: config,
}, config)

oauth2Provider := compose.Compose(config, fositeStore, hmacStrategy,
compose.OAuth2AuthorizeExplicitFactory,
Expand Down Expand Up @@ -343,18 +338,13 @@ func TestPreAuthorizeCodeGrantFlow(t *testing.T) {

config := new(fosite.Config)
config.EnforcePKCE = true
config.GlobalSecret = []byte("secret-for-signing-and-verifying-signatures")
config.AuthorizeCodeLifespan = time.Minute
config.AccessTokenLifespan = time.Hour

var hmacStrategy = &fositeoauth.HMACSHAStrategy{
Enigma: &hmac.HMACStrategy{
Config: &fosite.Config{
GlobalSecret: []byte("secret-for-signing-and-verifying-signatures"),
},
},
Config: &fosite.Config{
AuthorizeCodeLifespan: time.Minute,
AccessTokenLifespan: time.Hour,
},
}
var hmacStrategy = fositeoauth.NewHMACSHAStrategy(&hmac.HMACStrategy{
Config: config,
}, config)

oauth2Provider := compose.Compose(config, fositeStore, hmacStrategy,
compose.OAuth2AuthorizeExplicitFactory,
Expand Down
7 changes: 1 addition & 6 deletions pkg/storage/mongodb/arieskmsstore/aries_kms_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package arieskmsstore

import (
"context"
"reflect"
"testing"
"time"

Expand All @@ -17,8 +16,6 @@ import (
dc "github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"
arieskms "github.com/trustbloc/kms-go/kms"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -100,9 +97,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
7 changes: 1 addition & 6 deletions pkg/storage/mongodb/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ package mongodb_test

import (
"context"
"reflect"
"testing"
"time"

"github.com/cenkalti/backoff/v4"
dctest "github.com/ory/dockertest/v3"
dc "github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readpref"
Expand Down Expand Up @@ -79,9 +76,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package clientmanager_test

import (
"context"
"reflect"
"testing"
"time"

Expand All @@ -19,8 +18,6 @@ import (
"github.com/ory/fosite"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -165,9 +162,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
7 changes: 1 addition & 6 deletions pkg/storage/mongodb/cslindexstore/csl_index_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package cslindexstore
import (
"context"
_ "embed"
"reflect"
"testing"
"time"

Expand All @@ -19,8 +18,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/trustbloc/vc-go/verifiable"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -233,9 +230,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
7 changes: 1 addition & 6 deletions pkg/storage/mongodb/cslvcstore/csl_vc_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package cslvcstore
import (
"context"
_ "embed"
"reflect"
"testing"
"time"

Expand All @@ -19,8 +18,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/trustbloc/vc-go/verifiable"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"

Expand Down Expand Up @@ -214,9 +211,7 @@ func waitForMongoDBToBeUp() error {
func pingMongoDB() error {
var err error

tM := reflect.TypeOf(bson.M{})
reg := bson.NewRegistryBuilder().RegisterTypeMapEntry(bsontype.EmbeddedDocument, tM).Build()
clientOpts := options.Client().SetRegistry(reg).ApplyURI(mongoDBConnString)
clientOpts := options.Client().ApplyURI(mongoDBConnString)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
Expand Down
Loading

0 comments on commit 21028de

Please sign in to comment.