Merge pull request #4277 from dexidp/go_1_25

feat: update Go to 1.25
This commit is contained in:
Márk Sági-Kazár
2025-08-18 14:30:28 +02:00
committed by GitHub
29 changed files with 383 additions and 436 deletions
+3
View File
@@ -19,3 +19,6 @@ indent_style = tab
[{config.yaml.dist,config.dev.yaml}]
indent_size = 2
[.golangci.yaml]
indent_size = 2
+2 -2
View File
@@ -71,7 +71,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: "1.24"
go-version: "1.25"
- name: Download tool dependencies
run: make deps
@@ -142,7 +142,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: "1.24"
go-version: "1.25"
- name: Download golangci-lint
run: make bin/golangci-lint
+124
View File
@@ -0,0 +1,124 @@
version: "2"
run:
timeout: 5m
linters:
disable:
- staticcheck
- errcheck
enable:
- depguard
- dogsled
- exhaustive
- gochecknoinits
# - gocritic
- goprintffuncname
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
# - revive
# - sqlclosecheck
# - staticcheck
- unconvert
- unused
- whitespace
# Disable temporarily until everything works with Go 1.20
# - bodyclose
# - rowserrcheck
# - tparallel
# - unparam
# Disable temporarily until the following issue is resolved: https://github.com/golangci/golangci-lint/issues/3086
# - sqlclosecheck
# TODO: fix linter errors before enabling
# - exhaustivestruct
# - gochecknoglobals
# - errorlint
# - gocognit
# - godot
# - nlreturn
# - noctx
# - revive
# - wrapcheck
# TODO: fix linter errors before enabling (from original config)
# - dupl
# - errcheck
# - goconst
# - gocyclo
# - gosec
# - lll
# - scopelint
# unused
# - goheader
# - gomodguard
# don't enable:
# - asciicheck
# - funlen
# - godox
# - goerr113
# - gomnd
# - interfacer
# - maligned
# - nestif
# - testpackage
# - wsl
exclusions:
rules:
- linters:
- errcheck
- noctx
path: _test.go
presets:
- comments
- std-error-handling
settings:
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
gocritic:
# Enable multiple checks by tags. See "Tags" section in https://github.com/go-critic/go-critic#usage.
enabled-tags:
- diagnostic
- experimental
- opinionated
- style
disabled-checks:
- importShadow
- unnamedResult
depguard:
rules:
deprecated:
deny:
- pkg: "io/ioutil"
desc: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead."
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
# - golines
settings:
gci:
sections:
- standard
- default
- localmodule
# issues:
# exclude-dirs:
# - storage/ent/db # generated ent code
-97
View File
@@ -1,97 +0,0 @@
run:
timeout: 4m
linters-settings:
depguard:
rules:
deprecated:
deny:
- pkg: "io/ioutil"
desc: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead."
gci:
sections:
- standard
- default
- prefix(github.com/dexidp/dex)
goimports:
local-prefixes: github.com/dexidp/dex
linters:
disable-all: true
enable:
- depguard
- dogsled
- exhaustive
- gci
- gochecknoinits
- gocritic
- gofmt
- gofumpt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
# - revive
# - sqlclosecheck
- staticcheck
- stylecheck
- unconvert
- unused
- whitespace
# Disable temporarily until everything works with Go 1.20
# - bodyclose
# - rowserrcheck
# - tparallel
# - unparam
# Disable temporarily until everything works with Go 1.18
- typecheck
# Disable temporarily until the following issue is resolved: https://github.com/golangci/golangci-lint/issues/3086
# - sqlclosecheck
# TODO: fix linter errors before enabling
# - exhaustivestruct
# - gochecknoglobals
# - errorlint
# - gocognit
# - godot
# - nlreturn
# - noctx
# - revive
# - wrapcheck
# TODO: fix linter errors before enabling (from original config)
# - dupl
# - errcheck
# - goconst
# - gocyclo
# - gosec
# - lll
# - scopelint
# unused
# - goheader
# - gomodguard
# don't enable:
# - asciicheck
# - funlen
# - godox
# - goerr113
# - gomnd
# - interfacer
# - maligned
# - nestif
# - testpackage
# - wsl
issues:
exclude-dirs:
- storage/ent/db # generated ent code
+3 -3
View File
@@ -2,7 +2,7 @@ ARG BASE_IMAGE=alpine
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.6.1@sha256:923441d7c25f1e2eb5789f82d987693c47b8ed987c4ab3b075d6ed2b5d6779a3 AS xx
FROM --platform=$BUILDPLATFORM golang:1.24.3-alpine3.20@sha256:9f98e9893fbc798c710f3432baa1e0ac6127799127c3101d2c263c3a954f0abe AS builder
FROM --platform=$BUILDPLATFORM golang:1.25.0-alpine3.22@sha256:f18a072054848d87a8077455f0ac8a25886f2397f88bfdd222d6fafbb5bba440 AS builder
COPY --from=xx / /
@@ -50,8 +50,8 @@ ARG TARGETVARIANT
ENV GOMPLATE_VERSION=v4.3.3
RUN wget -O /usr/local/bin/gomplate \
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT}" \
&& chmod +x /usr/local/bin/gomplate
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT}" \
&& chmod +x /usr/local/bin/gomplate
# For Dependabot to detect base image versions
FROM alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1 AS alpine
+3 -3
View File
@@ -17,7 +17,7 @@ export GOBIN=$(PWD)/bin
LD_FLAGS="-w -X main.version=$(VERSION)"
# Dependency versions
GOLANGCI_VERSION = 1.64.5
GOLANGCI_VERSION = 2.4.0
GOTESTSUM_VERSION ?= 1.12.0
PROTOC_VERSION = 29.3
@@ -132,7 +132,7 @@ testrace: ## Test go code and check for possible race conditions.
testall: testrace ## Run all tests for go code.
.PHONY: lint lint-fix
.PHONY: lint
lint: ## Run linter.
@golangci-lint version
@golangci-lint run
@@ -140,7 +140,7 @@ lint: ## Run linter.
.PHONY: fix
fix: ## Fix lint violations.
@golangci-lint version
@golangci-lint run --fix
@golangci-lint fmt
docker-compose.override.yaml:
cp docker-compose.override.yaml.dist docker-compose.override.yaml
@@ -113,7 +113,7 @@ func TestIdentityFromCrowdUser(t *testing.T) {
expectEquals(t, user.Name, "testuser")
expectEquals(t, user.Email, "testuser@example.com")
// Test unconfigured behaviour
// Test unconfigured behavior
i := c.identityFromCrowdUser(user)
expectEquals(t, i.UserID, "12345")
expectEquals(t, i.Username, "testuser")
Generated
+66 -102
View File
@@ -9,16 +9,20 @@
"devenv"
],
"git-hooks": [
"devenv"
"devenv",
"git-hooks"
],
"nixpkgs": "nixpkgs"
"nixpkgs": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1737621947,
"narHash": "sha256-8HFvG7fvIFbgtaYAY2628Tb89fA55nPm2jSiNs0/Cws=",
"lastModified": 1748883665,
"narHash": "sha256-R0W7uAg+BLoHjMRMQ8+oiSbTq8nkGz5RDpQ+ZfxxP3A=",
"owner": "cachix",
"repo": "cachix",
"rev": "f65a3cd5e339c223471e64c051434616e18cc4f5",
"rev": "f707778d902af4d62d8dd92c269f8e70de09acbe",
"type": "github"
},
"original": {
@@ -34,14 +38,14 @@
"flake-compat": "flake-compat",
"git-hooks": "git-hooks",
"nix": "nix",
"nixpkgs": "nixpkgs_3"
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1739858011,
"narHash": "sha256-L7ci8K32cyvwOFNMQc2LD3EHm5w8dnh0Qrtxe7Fggrs=",
"lastModified": 1755355634,
"narHash": "sha256-3UNeb5pBLHtTyYIkzF/3+2YlAKf6OuWQYUQO+qmInA4=",
"owner": "cachix",
"repo": "devenv",
"rev": "e963201a79150f913e4b95be1cfef8c4a301679c",
"rev": "85e78cbe26467a2c23c9d34869235740132d749f",
"type": "github"
},
"original": {
@@ -53,11 +57,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
@@ -75,11 +79,11 @@
]
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"lastModified": 1733312601,
"narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9",
"type": "github"
},
"original": {
@@ -93,11 +97,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1738453229,
"narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=",
"lastModified": 1754487366,
"narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd",
"rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18",
"type": "github"
},
"original": {
@@ -109,7 +113,8 @@
"git-hooks": {
"inputs": {
"flake-compat": [
"devenv"
"devenv",
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
@@ -118,11 +123,11 @@
]
},
"locked": {
"lastModified": 1737465171,
"narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=",
"lastModified": 1750779888,
"narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17",
"rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d",
"type": "github"
},
"original": {
@@ -153,106 +158,50 @@
"type": "github"
}
},
"libgit2": {
"flake": false,
"locked": {
"lastModified": 1697646580,
"narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=",
"owner": "libgit2",
"repo": "libgit2",
"rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5",
"type": "github"
},
"original": {
"owner": "libgit2",
"repo": "libgit2",
"type": "github"
}
},
"nix": {
"inputs": {
"flake-compat": [
"devenv"
"devenv",
"flake-compat"
],
"flake-parts": "flake-parts",
"libgit2": "libgit2",
"nixpkgs": "nixpkgs_2",
"git-hooks-nix": [
"devenv",
"git-hooks"
],
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-23-11": [
"devenv"
],
"nixpkgs-regression": [
"devenv"
],
"pre-commit-hooks": [
"devenv"
]
},
"locked": {
"lastModified": 1734114420,
"narHash": "sha256-n52PUzub5jZWc8nI/sR7UICOheU8rNA+YZ73YaHeCBg=",
"owner": "domenkozar",
"lastModified": 1755029779,
"narHash": "sha256-3+GHIYGg4U9XKUN4rg473frIVNn8YD06bjwxKS1IPrU=",
"owner": "cachix",
"repo": "nix",
"rev": "bde6a1a0d1f2af86caa4d20d23eca019f3d57eee",
"rev": "b0972b0eee6726081d10b1199f54de6d2917f861",
"type": "github"
},
"original": {
"owner": "domenkozar",
"ref": "devenv-2.24",
"owner": "cachix",
"ref": "devenv-2.30",
"repo": "nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733212471,
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1738452942,
"narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1717432640,
"narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "88269ab3044128b7c2f4c7d68448b2fb50456870",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "release-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1733477122,
"narHash": "sha256-qamMCz5mNpQmgBwc8SB5tVMlD5sbwVIToVZtSxMph9s=",
"lastModified": 1750441195,
"narHash": "sha256-yke+pm+MdgRb6c0dPt8MgDhv7fcBbdjmv1ZceNTyzKg=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857",
"rev": "0ceffe312871b443929ff3006960d29b120dc627",
"type": "github"
},
"original": {
@@ -262,13 +211,28 @@
"type": "github"
}
},
"nixpkgs_4": {
"nixpkgs-lib": {
"locked": {
"lastModified": 1739834344,
"narHash": "sha256-PUAcU3YlKNFYrBBHkqshO4wRfMunzhMTEIH1dyhjTtk=",
"lastModified": 1753579242,
"narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1755268003,
"narHash": "sha256-nNaeJjo861wFR0tjHDyCnHs1rbRtrMgxAKMoig9Sj/w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f0295845e58ada369322524631821b01c0db13a7",
"rev": "32f313e49e42f715491e1ea7b306a87c16fe0388",
"type": "github"
},
"original": {
@@ -282,7 +246,7 @@
"inputs": {
"devenv": "devenv",
"flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_4"
"nixpkgs": "nixpkgs_2"
}
}
},
+5 -2
View File
@@ -27,14 +27,17 @@
languages = {
go = {
enable = true;
package = pkgs.go_1_24;
package = pkgs.go_1_25;
};
};
packages = with pkgs; [
gnumake
golangci-lint
# golangci-lint
(golangci-lint.override (o: {
buildGoModule = pkgs.buildGo125Module;
}))
gotestsum
protobuf
protoc-gen-go
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/dexidp/dex
go 1.24.0
go 1.25.0
require (
cloud.google.com/go/compute/metadata v0.8.0
+56 -61
View File
@@ -1,10 +1,9 @@
package server
import (
"context"
"log/slog"
"net"
"os"
"slices"
"strings"
"testing"
"time"
@@ -29,8 +28,12 @@ type apiClient struct {
Close func()
}
func newLogger(t *testing.T) *slog.Logger {
return slog.New(slog.NewTextHandler(t.Output(), &slog.HandlerOptions{Level: slog.LevelDebug}))
}
// newAPI constructs a gRCP client connected to a backing server.
func newAPI(s storage.Storage, logger *slog.Logger, t *testing.T) *apiClient {
func newAPI(t *testing.T, s storage.Storage, logger *slog.Logger) *apiClient {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
@@ -59,13 +62,14 @@ func newAPI(s storage.Storage, logger *slog.Logger, t *testing.T) *apiClient {
// Attempts to create, update and delete a test Password
func TestPassword(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
email := "test@example.com"
p := api.Password{
Email: email,
@@ -168,10 +172,10 @@ func TestPassword(t *testing.T) {
// Ensures checkCost returns expected values
func TestCheckCost(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
tests := []struct {
@@ -221,13 +225,13 @@ func TestCheckCost(t *testing.T) {
// Attempts to list and revoke an existing refresh token.
func TestRefreshToken(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
// Creating a storage with an existing refresh token and offline session for the user.
id := storage.NewID()
@@ -330,12 +334,13 @@ func TestRefreshToken(t *testing.T) {
}
func TestUpdateClient(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
createClient := func(t *testing.T, clientId string) {
resp, err := client.CreateClient(ctx, &api.CreateClientReq{
@@ -463,13 +468,13 @@ func TestUpdateClient(t *testing.T) {
t.Errorf("expected stored client with LogoURL: %s, found %s", tc.req.LogoUrl, client.LogoURL)
}
for _, redirectURI := range tc.req.RedirectUris {
found := find(redirectURI, client.RedirectURIs)
found := slices.Contains(client.RedirectURIs, redirectURI)
if !found {
t.Errorf("expected redirect URI: %s", redirectURI)
}
}
for _, peer := range tc.req.TrustedPeers {
found := find(peer, client.TrustedPeers)
found := slices.Contains(client.TrustedPeers, peer)
if !found {
t.Errorf("expected trusted peer: %s", peer)
}
@@ -483,26 +488,17 @@ func TestUpdateClient(t *testing.T) {
}
}
func find(item string, items []string) bool {
for _, i := range items {
if item == i {
return true
}
}
return false
}
func TestCreateConnector(t *testing.T) {
os.Setenv("DEX_API_CONNECTORS_CRUD", "true")
defer os.Unsetenv("DEX_API_CONNECTORS_CRUD")
logger := slog.New(slog.DiscardHandler)
t.Setenv("DEX_API_CONNECTORS_CRUD", "true")
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
connectorID := "connector123"
connectorName := "TestConnector"
connectorType := "TestType"
@@ -543,16 +539,16 @@ func TestCreateConnector(t *testing.T) {
}
func TestUpdateConnector(t *testing.T) {
os.Setenv("DEX_API_CONNECTORS_CRUD", "true")
defer os.Unsetenv("DEX_API_CONNECTORS_CRUD")
logger := slog.New(slog.DiscardHandler)
t.Setenv("DEX_API_CONNECTORS_CRUD", "true")
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
connectorID := "connector123"
newConnectorName := "UpdatedConnector"
newConnectorType := "UpdatedType"
@@ -611,16 +607,16 @@ func TestUpdateConnector(t *testing.T) {
}
func TestDeleteConnector(t *testing.T) {
os.Setenv("DEX_API_CONNECTORS_CRUD", "true")
defer os.Unsetenv("DEX_API_CONNECTORS_CRUD")
logger := slog.New(slog.DiscardHandler)
t.Setenv("DEX_API_CONNECTORS_CRUD", "true")
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
connectorID := "connector123"
// Create a connector for testing
@@ -655,16 +651,15 @@ func TestDeleteConnector(t *testing.T) {
}
func TestListConnectors(t *testing.T) {
os.Setenv("DEX_API_CONNECTORS_CRUD", "true")
defer os.Unsetenv("DEX_API_CONNECTORS_CRUD")
logger := slog.New(slog.DiscardHandler)
t.Setenv("DEX_API_CONNECTORS_CRUD", "true")
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
// Create connectors for testing
createReq1 := api.CreateConnectorReq{
@@ -698,13 +693,13 @@ func TestListConnectors(t *testing.T) {
}
func TestMissingConnectorsCRUDFeatureFlag(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
// Create connectors for testing
createReq1 := api.CreateConnectorReq{
@@ -735,13 +730,13 @@ func TestMissingConnectorsCRUDFeatureFlag(t *testing.T) {
}
func TestListClients(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
logger := newLogger(t)
s := memory.New(logger)
client := newAPI(s, logger, t)
client := newAPI(t, s, logger)
defer client.Close()
ctx := context.Background()
ctx := t.Context()
// List Clients
listResp, err := client.ListClients(ctx, &api.ListClientReq{})
+9 -18
View File
@@ -2,7 +2,6 @@ package server
import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
@@ -20,10 +19,8 @@ func TestDeviceVerificationURI(t *testing.T) {
t0 := time.Now()
now := func() time.Time { return t0 }
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
})
@@ -101,11 +98,8 @@ func TestHandleDeviceCode(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
})
@@ -364,11 +358,10 @@ func TestDeviceCallback(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
// c.Issuer = c.Issuer + "/non-root-path"
c.Now = now
})
@@ -658,11 +651,10 @@ func TestDeviceTokenResponse(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
})
@@ -715,7 +707,7 @@ func TestDeviceTokenResponse(t *testing.T) {
}
func expectJSONErrorResponse(testCase string, body []byte, expectedError string, t *testing.T) {
jsonMap := make(map[string]interface{})
jsonMap := make(map[string]any)
err := json.Unmarshal(body, &jsonMap)
if err != nil {
t.Errorf("Unexpected error unmarshalling response: %v", err)
@@ -792,11 +784,10 @@ func TestVerifyCodeResponse(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
})
+16 -36
View File
@@ -24,10 +24,7 @@ import (
)
func TestHandleHealth(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, server := newTestServer(ctx, t, nil)
httpServer, server := newTestServer(t, nil)
defer httpServer.Close()
rr := httptest.NewRecorder()
@@ -38,10 +35,7 @@ func TestHandleHealth(t *testing.T) {
}
func TestHandleDiscovery(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, server := newTestServer(ctx, t, nil)
httpServer, server := newTestServer(t, nil)
defer httpServer.Close()
rr := httptest.NewRecorder()
@@ -108,10 +102,7 @@ func TestHandleDiscovery(t *testing.T) {
}
func TestHandleHealthFailure(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, server := newTestServer(ctx, t, func(c *Config) {
httpServer, server := newTestServer(t, func(c *Config) {
c.HealthChecker = gosundheit.New()
c.HealthChecker.RegisterCheck(
@@ -143,10 +134,7 @@ func (*emptyStorage) GetAuthRequest(context.Context, string) (storage.AuthReques
}
func TestHandleInvalidOAuth2Callbacks(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, server := newTestServer(ctx, t, func(c *Config) {
httpServer, server := newTestServer(t, func(c *Config) {
c.Storage = &emptyStorage{c.Storage}
})
defer httpServer.Close()
@@ -171,10 +159,7 @@ func TestHandleInvalidOAuth2Callbacks(t *testing.T) {
}
func TestHandleInvalidSAMLCallbacks(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, server := newTestServer(ctx, t, func(c *Config) {
httpServer, server := newTestServer(t, func(c *Config) {
c.Storage = &emptyStorage{c.Storage}
})
defer httpServer.Close()
@@ -251,10 +236,9 @@ func TestHandleAuthCode(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
httpServer, s := newTestServer(ctx, t, func(c *Config) { c.Issuer += "/non-root-path" })
httpServer, s := newTestServer(t, func(c *Config) { c.Issuer += "/non-root-path" })
defer httpServer.Close()
p, err := oidc.NewProvider(ctx, httpServer.URL)
@@ -303,7 +287,7 @@ func TestHandleAuthCode(t *testing.T) {
}
func mockConnectorDataTestStorage(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
c := storage.Client{
ID: "test",
Secret: "barfoo",
@@ -339,8 +323,7 @@ func mockConnectorDataTestStorage(t *testing.T, s storage.Storage) {
}
func TestHandlePassword(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
tests := []struct {
name string
@@ -361,7 +344,7 @@ func TestHandlePassword(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.PasswordConnector = "test"
c.Now = time.Now
})
@@ -420,8 +403,7 @@ func TestHandlePassword(t *testing.T) {
}
func TestHandlePasswordLoginWithSkipApproval(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
connID := "mockPw"
authReqID := "test"
@@ -525,7 +507,7 @@ func TestHandlePasswordLoginWithSkipApproval(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.SkipApprovalScreen = tc.skipApproval
c.Now = time.Now
})
@@ -574,8 +556,7 @@ func TestHandlePasswordLoginWithSkipApproval(t *testing.T) {
}
func TestHandleConnectorCallbackWithSkipApproval(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
connID := "mock"
authReqID := "test"
@@ -679,7 +660,7 @@ func TestHandleConnectorCallbackWithSkipApproval(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.SkipApprovalScreen = tc.skipApproval
c.Now = time.Now
})
@@ -780,9 +761,8 @@ func TestHandleTokenExchange(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, s := newTestServer(ctx, t, func(c *Config) {
ctx := t.Context()
httpServer, s := newTestServer(t, func(c *Config) {
c.Storage.CreateClient(ctx, storage.Client{
ID: "client_1",
Secret: "secret_1",
+8 -15
View File
@@ -2,7 +2,6 @@ package server
import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
@@ -29,7 +28,7 @@ func toJSON(a interface{}) string {
}
func mockTestStorage(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
c := storage.Client{
ID: "test",
Secret: "barfoo",
@@ -139,11 +138,8 @@ func TestGetTokenFromRequestSuccess(t *testing.T) {
t0 := time.Now()
now := func() time.Time { return t0 }
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
})
@@ -201,11 +197,9 @@ func TestGetTokenFromRequestFailure(t *testing.T) {
t0 := time.Now()
now := func() time.Time { return t0 }
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
})
@@ -238,19 +232,20 @@ func TestGetTokenFromRequestFailure(t *testing.T) {
func TestHandleIntrospect(t *testing.T) {
t0 := time.Now()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
// Setup a dex server.
now := func() time.Time { return t0 }
logger := newLogger(t)
refreshTokenPolicy, err := NewRefreshTokenPolicy(logger, false, "", "24h", "")
if err != nil {
t.Fatalf("failed to prepare rotation policy: %v", err)
}
refreshTokenPolicy.now = now
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.RefreshTokenPolicy = refreshTokenPolicy
c.Now = now
@@ -361,11 +356,9 @@ func TestIntrospectErrHelper(t *testing.T) {
t0 := time.Now()
now := func() time.Time { return t0 }
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
})
+4 -7
View File
@@ -1,7 +1,6 @@
package server
import (
"context"
"crypto/rand"
"crypto/rsa"
"net/http"
@@ -323,10 +322,7 @@ func TestParseAuthorizationRequest(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, server := newTestServerMultipleConnectors(ctx, t, func(c *Config) {
httpServer, server := newTestServerMultipleConnectors(t, func(c *Config) {
c.SupportedResponseTypes = tc.supportedResponseTypes
c.Storage = storage.WithStaticClients(c.Storage, tc.clients)
})
@@ -598,8 +594,9 @@ func TestValidRedirectURI(t *testing.T) {
}
func TestStorageKeySet(t *testing.T) {
logger := newLogger(t)
s := memory.New(logger)
if err := s.UpdateKeys(context.TODO(), func(keys storage.Keys) (storage.Keys, error) {
if err := s.UpdateKeys(t.Context(), func(keys storage.Keys) (storage.Keys, error) {
keys.SigningKey = &jose.JSONWebKey{
Key: testKey,
KeyID: "testkey",
@@ -673,7 +670,7 @@ func TestStorageKeySet(t *testing.T) {
keySet := &storageKeySet{s}
_, err = keySet.VerifySignature(context.Background(), jwt)
_, err = keySet.VerifySignature(t.Context(), jwt)
if (err != nil && !tc.wantErr) || (err == nil && tc.wantErr) {
t.Fatalf("wantErr = %v, but got err = %v", tc.wantErr, err)
}
+2 -6
View File
@@ -2,7 +2,6 @@ package server
import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/http/httptest"
@@ -18,7 +17,7 @@ import (
)
func mockRefreshTokenTestStorage(t *testing.T, s storage.Storage, useObsolete bool) {
ctx := context.Background()
ctx := t.Context()
c := storage.Client{
ID: "test",
Secret: "barfoo",
@@ -153,11 +152,8 @@ func TestRefreshTokenExpirationScenarios(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(*testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.RefreshTokenPolicy = tc.policy
c.Now = func() time.Time { return t0 }
})
+38 -41
View File
@@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"net/http"
"net/http/httptest"
"net/http/httputil"
@@ -76,14 +75,15 @@ FDWV28nTP9sqbtsmU8Tem2jzMvZ7C/Q0AuDoKELFUpux8shm8wfIhyaPnXUGZoAZ
Np4vUwMSYV5mopESLWOg3loBxKyLGFtgGKVCjGiQvy6zISQ4fQo=
-----END RSA PRIVATE KEY-----`)
var logger = slog.New(slog.DiscardHandler)
func newTestServer(ctx context.Context, t *testing.T, updateConfig func(c *Config)) (*httptest.Server, *Server) {
func newTestServer(t *testing.T, updateConfig func(c *Config)) (*httptest.Server, *Server) {
var server *Server
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server.ServeHTTP(w, r)
}))
logger := newLogger(t)
ctx := t.Context()
config := Config{
Issuer: s.URL,
Storage: memory.New(logger),
@@ -135,12 +135,15 @@ func newTestServer(ctx context.Context, t *testing.T, updateConfig func(c *Confi
return s, server
}
func newTestServerMultipleConnectors(ctx context.Context, t *testing.T, updateConfig func(c *Config)) (*httptest.Server, *Server) {
func newTestServerMultipleConnectors(t *testing.T, updateConfig func(c *Config)) (*httptest.Server, *Server) {
var server *Server
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server.ServeHTTP(w, r)
}))
logger := newLogger(t)
ctx := t.Context()
config := Config{
Issuer: s.URL,
Storage: memory.New(logger),
@@ -183,21 +186,16 @@ func newTestServerMultipleConnectors(ctx context.Context, t *testing.T, updateCo
}
func TestNewTestServer(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
newTestServer(ctx, t, nil)
newTestServer(t, nil)
}
func TestDiscovery(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, _ := newTestServer(ctx, t, func(c *Config) {
httpServer, _ := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
})
defer httpServer.Close()
p, err := oidc.NewProvider(ctx, httpServer.URL)
p, err := oidc.NewProvider(t.Context(), httpServer.URL)
if err != nil {
t.Fatalf("failed to get provider: %v", err)
}
@@ -734,11 +732,10 @@ func TestOAuth2CodeFlow(t *testing.T) {
tests := makeOAuth2Tests(clientID, clientSecret, now)
for _, tc := range tests.tests {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
c.IDTokensValidFor = idTokensValidFor
@@ -890,10 +887,9 @@ func TestOAuth2CodeFlow(t *testing.T) {
}
func TestOAuth2ImplicitFlow(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
// Enable support for the implicit flow.
c.SupportedResponseTypes = []string{"code", "token", "id_token"}
})
@@ -1026,10 +1022,9 @@ func TestOAuth2ImplicitFlow(t *testing.T) {
}
func TestCrossClientScopes(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
})
defer httpServer.Close()
@@ -1149,10 +1144,9 @@ func TestCrossClientScopes(t *testing.T) {
}
func TestCrossClientScopesWithAzpInAudienceByDefault(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
})
defer httpServer.Close()
@@ -1271,7 +1265,9 @@ func TestCrossClientScopesWithAzpInAudienceByDefault(t *testing.T) {
}
func TestPasswordDB(t *testing.T) {
ctx := context.Background()
ctx := t.Context()
logger := newLogger(t)
s := memory.New(logger)
conn := newPasswordDB(s)
@@ -1323,7 +1319,7 @@ func TestPasswordDB(t *testing.T) {
}
for _, tc := range tests {
ident, valid, err := conn.Login(context.Background(), connector.Scopes{}, tc.username, tc.password)
ident, valid, err := conn.Login(t.Context(), connector.Scopes{}, tc.username, tc.password)
if err != nil {
if !tc.wantErr {
t.Errorf("%s: %v", tc.name, err)
@@ -1355,6 +1351,7 @@ func TestPasswordDB(t *testing.T) {
}
func TestPasswordDBUsernamePrompt(t *testing.T) {
logger := newLogger(t)
s := memory.New(logger)
conn := newPasswordDB(s)
@@ -1377,7 +1374,8 @@ func (s storageWithKeysTrigger) GetKeys(ctx context.Context) (storage.Keys, erro
func TestKeyCacher(t *testing.T) {
tNow := time.Now()
now := func() time.Time { return tNow }
ctx := context.TODO()
ctx := t.Context()
logger := newLogger(t)
s := memory.New(logger)
tests := []struct {
@@ -1428,7 +1426,7 @@ func TestKeyCacher(t *testing.T) {
for i, tc := range tests {
gotCall = false
tc.before()
s.GetKeys(context.TODO())
s.GetKeys(t.Context())
if gotCall != tc.wantCallToStorage {
t.Errorf("case %d: expected call to storage=%t got call to storage=%t", i, tc.wantCallToStorage, gotCall)
}
@@ -1470,10 +1468,10 @@ type oauth2Client struct {
func TestRefreshTokenFlow(t *testing.T) {
state := "state"
now := time.Now
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
httpServer, s := newTestServer(ctx, t, func(c *Config) {
ctx := t.Context()
httpServer, s := newTestServer(t, func(c *Config) {
c.Now = now
})
defer httpServer.Close()
@@ -1604,11 +1602,10 @@ func TestOAuth2DeviceFlow(t *testing.T) {
for _, testCase := range testCases {
for _, tc := range testCase.oauth2Tests.tests {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
// Setup a dex server.
httpServer, s := newTestServer(ctx, t, func(c *Config) {
httpServer, s := newTestServer(t, func(c *Config) {
c.Issuer += "/non-root-path"
c.Now = now
c.IDTokensValidFor = idTokensValidFor
@@ -1789,17 +1786,16 @@ func TestServerSupportedGrants(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
_, srv := newTestServer(context.TODO(), t, tc.config)
_, srv := newTestServer(t, tc.config)
require.Equal(t, tc.resGrants, srv.supportedGrantTypes)
})
}
}
func TestHeaders(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
httpServer, _ := newTestServer(ctx, t, func(c *Config) {
httpServer, _ := newTestServer(t, func(c *Config) {
c.Headers = map[string][]string{
"Strict-Transport-Security": {"max-age=31536000; includeSubDomains"},
}
@@ -1818,8 +1814,7 @@ func TestHeaders(t *testing.T) {
}
func TestConnectorFailureHandling(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
tests := []struct {
name string
@@ -1959,6 +1954,8 @@ func TestConnectorFailureHandling(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
logger := newLogger(t)
config := Config{
Issuer: "http://localhost",
Storage: memory.New(logger),
+14 -14
View File
@@ -24,10 +24,10 @@ type subTest struct {
run func(t *testing.T, s storage.Storage)
}
func runTests(t *testing.T, newStorage func() storage.Storage, tests []subTest) {
func runTests(t *testing.T, newStorage func(t *testing.T) storage.Storage, tests []subTest) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
s := newStorage()
s := newStorage(t)
test.run(t, s)
s.Close()
})
@@ -37,7 +37,7 @@ func runTests(t *testing.T, newStorage func() storage.Storage, tests []subTest)
// RunTests runs a set of conformance tests against a storage. newStorage should
// return an initialized but empty storage. The storage will be closed at the
// end of each test run.
func RunTests(t *testing.T, newStorage func() storage.Storage) {
func RunTests(t *testing.T, newStorage func(t *testing.T) storage.Storage) {
runTests(t, newStorage, []subTest{
{"AuthCodeCRUD", testAuthCodeCRUD},
{"AuthRequestCRUD", testAuthRequestCRUD},
@@ -81,7 +81,7 @@ func mustBeErrAlreadyExists(t *testing.T, kind string, err error) {
}
func testAuthRequestCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
codeChallenge := storage.PKCE{
CodeChallenge: "code_challenge_test",
CodeChallengeMethod: "plain",
@@ -181,7 +181,7 @@ func testAuthRequestCRUD(t *testing.T, s storage.Storage) {
}
func testAuthCodeCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
a1 := storage.AuthCode{
ID: storage.NewID(),
ClientID: "client1",
@@ -259,7 +259,7 @@ func testAuthCodeCRUD(t *testing.T, s storage.Storage) {
}
func testClientCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
id1 := storage.NewID()
c1 := storage.Client{
ID: id1,
@@ -329,7 +329,7 @@ func testClientCRUD(t *testing.T, s storage.Storage) {
}
func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
id := storage.NewID()
refresh := storage.RefreshToken{
ID: id,
@@ -448,7 +448,7 @@ func (n byEmail) Less(i, j int) bool { return n[i].Email < n[j].Email }
func (n byEmail) Swap(i, j int) { n[i], n[j] = n[j], n[i] }
func testPasswordCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
// Use bcrypt.MinCost to keep the tests short.
passwordHash1, err := bcrypt.GenerateFromPassword([]byte("secret"), bcrypt.MinCost)
if err != nil {
@@ -539,7 +539,7 @@ func testPasswordCRUD(t *testing.T, s storage.Storage) {
}
func testOfflineSessionCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
userID1 := storage.NewID()
session1 := storage.OfflineSessions{
UserID: userID1,
@@ -614,7 +614,7 @@ func testOfflineSessionCRUD(t *testing.T, s storage.Storage) {
}
func testConnectorCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
id1 := storage.NewID()
config1 := []byte(`{"issuer": "https://accounts.google.com"}`)
c1 := storage.Connector{
@@ -754,7 +754,7 @@ func testKeysCRUD(t *testing.T, s storage.Storage) {
}
func testGC(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
est, err := time.LoadLocation("America/New_York")
if err != nil {
t.Fatal(err)
@@ -942,7 +942,7 @@ func testGC(t *testing.T, s storage.Storage) {
// testTimezones tests that backends either fully support timezones or
// do the correct standardization.
func testTimezones(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
est, err := time.LoadLocation("America/New_York")
if err != nil {
t.Fatal(err)
@@ -987,7 +987,7 @@ func testTimezones(t *testing.T, s storage.Storage) {
}
func testDeviceRequestCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
d1 := storage.DeviceRequest{
UserCode: storage.NewUserCode(),
DeviceCode: storage.NewID(),
@@ -1017,7 +1017,7 @@ func testDeviceRequestCRUD(t *testing.T, s storage.Storage) {
}
func testDeviceTokenCRUD(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
codeChallenge := storage.PKCE{
CodeChallenge: "code_challenge_test",
CodeChallengeMethod: "plain",
+4 -4
View File
@@ -17,7 +17,7 @@ import (
// This call is separate from RunTests because some storage perform extremely
// poorly under deadlocks, such as SQLite3, while others may be working towards
// conformance.
func RunTransactionTests(t *testing.T, newStorage func() storage.Storage) {
func RunTransactionTests(t *testing.T, newStorage func(t *testing.T) storage.Storage) {
runTests(t, newStorage, []subTest{
{"AuthRequestConcurrentUpdate", testAuthRequestConcurrentUpdate},
{"ClientConcurrentUpdate", testClientConcurrentUpdate},
@@ -27,7 +27,7 @@ func RunTransactionTests(t *testing.T, newStorage func() storage.Storage) {
}
func testClientConcurrentUpdate(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
c := storage.Client{
ID: storage.NewID(),
Secret: "foobar",
@@ -57,7 +57,7 @@ func testClientConcurrentUpdate(t *testing.T, s storage.Storage) {
}
func testAuthRequestConcurrentUpdate(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
a := storage.AuthRequest{
ID: storage.NewID(),
ClientID: "foobar",
@@ -102,7 +102,7 @@ func testAuthRequestConcurrentUpdate(t *testing.T, s storage.Storage) {
}
func testPasswordConcurrentUpdate(t *testing.T, s storage.Storage) {
ctx := context.Background()
ctx := t.Context()
// Use bcrypt.MinCost to keep the tests short.
passwordHash, err := bcrypt.GenerateFromPassword([]byte("secret"), bcrypt.MinCost)
if err != nil {
+1 -1
View File
@@ -81,7 +81,7 @@ func (m *MySQL) driver() (*entSQL.Driver, error) {
}
if m.MaxIdleConns == 0 {
/* Override default behaviour to fix https://github.com/dexidp/dex/issues/1608 */
/* Override default behavior to fix https://github.com/dexidp/dex/issues/1608 */
drv.DB().SetMaxIdleConns(0)
} else {
drv.DB().SetMaxIdleConns(m.MaxIdleConns)

Some files were not shown because too many files have changed in this diff Show More