Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
chore: testIDP using static defaults for easier reuse
  • Loading branch information
Emyrk committed Jan 12, 2024
commit 87b5447f620ab6e29cc3a4c6e5516409614e151e
File renamed without changes.
11 changes: 11 additions & 0 deletions cmd/testidp/main.go → scripts/testidp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import (
"os"
"os/signal"
"testing"
"time"

"github.com/golang-jwt/jwt/v4"

"github.com/coder/coder/v2/coderd/coderdtest/oidctest"
)

// Flags
var (
expiry = flag.Duration("expiry", time.Minute*5, "Token expiry")
clientID = flag.String("client-id", "static-client-id", "Client ID, set empty to be random")
clientSecret = flag.String("client-sec", "static-client-secret", "Client Secret, set empty to be random")
)

func main() {
testing.Init()
_ = flag.Set("test.timeout", "0")
Expand All @@ -37,6 +45,9 @@ func RunIDP() func(t *testing.T) {
oidctest.WithServing(),
oidctest.WithStaticUserInfo(jwt.MapClaims{}),
oidctest.WithDefaultIDClaims(jwt.MapClaims{}),
oidctest.WithDefaultExpire(*expiry),
oidctest.WithStaticCredentials(*clientID, *clientSecret),
oidctest.WithIssuer("http://localhost:4500"),
)
id, sec := idp.AppCredentials()
prov := idp.WellknownConfig()
Expand Down