Skip to content

Commit e451b3d

Browse files
committed
fix: review comments
1 parent 5bada13 commit e451b3d

17 files changed

Lines changed: 62 additions & 57 deletions
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
ALTER TABLE "oidc_codes" DROP COLUMN "code_challenge";
2-
ALTER TABLE "oidc_codes" DROP COLUMN "code_challenge_method";
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
ALTER TABLE "oidc_codes" ADD COLUMN "code_challenge" TEXT DEFAULT "";
2-
ALTER TABLE "oidc_codes" ADD COLUMN "code_challenge_method" TEXT DEFAULT "";

internal/controller/context_controller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import (
1010
"github.com/steveiliop56/tinyauth/internal/config"
1111
"github.com/steveiliop56/tinyauth/internal/controller"
1212
"github.com/steveiliop56/tinyauth/internal/utils"
13+
"github.com/steveiliop56/tinyauth/internal/utils/tlog"
1314
"github.com/stretchr/testify/assert"
1415
)
1516

1617
func TestContextController(t *testing.T) {
18+
tlog.NewTestLogger().Init()
1719
controllerConfig := controller.ContextControllerConfig{
1820
Providers: []controller.Provider{
1921
{

internal/controller/health_controller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import (
88

99
"github.com/gin-gonic/gin"
1010
"github.com/steveiliop56/tinyauth/internal/controller"
11+
"github.com/steveiliop56/tinyauth/internal/utils/tlog"
1112
"github.com/stretchr/testify/assert"
1213
)
1314

1415
func TestHealthController(t *testing.T) {
16+
tlog.NewTestLogger().Init()
1517
tests := []struct {
1618
description string
1719
path string

internal/controller/oidc_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ func (controller *OIDCController) Token(c *gin.Context) {
309309
return
310310
}
311311

312-
ok := controller.oidc.ValidatePKCE(entry.CodeChallenge, entry.CodeChallengeMethod, req.CodeVerifier)
312+
tlog.App.Debug().Str("challenge", entry.CodeChallenge).Str("verifier", req.CodeVerifier).Msg("Validating PKCE")
313+
ok := controller.oidc.ValidatePKCE(entry.CodeChallenge, req.CodeVerifier)
313314

314315
if !ok {
315316
tlog.App.Warn().Msg("PKCE validation failed")

internal/controller/oidc_controller_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ import (
1717
"github.com/steveiliop56/tinyauth/internal/controller"
1818
"github.com/steveiliop56/tinyauth/internal/repository"
1919
"github.com/steveiliop56/tinyauth/internal/service"
20+
"github.com/steveiliop56/tinyauth/internal/utils/tlog"
2021
"github.com/stretchr/testify/assert"
2122
"github.com/stretchr/testify/require"
2223
)
2324

2425
func TestOIDCController(t *testing.T) {
26+
tlog.NewTestLogger().Init()
2527
tempDir := t.TempDir()
2628

2729
oidcServiceCfg := service.OIDCServiceConfig{
@@ -473,6 +475,7 @@ func TestOIDCController(t *testing.T) {
473475
assert.NotEmpty(t, code)
474476

475477
// Now exchange the code for a token
478+
recorder = httptest.NewRecorder()
476479
tokenReqBody := controller.TokenRequest{
477480
GrantType: "authorization_code",
478481
Code: code,
@@ -499,7 +502,7 @@ func TestOIDCController(t *testing.T) {
499502
hasher := sha256.New()
500503
hasher.Write([]byte("some-challenge"))
501504
codeChallenge := hasher.Sum(nil)
502-
codeChallengeEncoded := base64.URLEncoding.EncodeToString(codeChallenge)
505+
codeChallengeEncoded := base64.RawURLEncoding.EncodeToString(codeChallenge)
503506
reqBody := service.AuthorizeRequest{
504507
Scope: "openid",
505508
ResponseType: "code",
@@ -533,6 +536,7 @@ func TestOIDCController(t *testing.T) {
533536
assert.NotEmpty(t, code)
534537

535538
// Now exchange the code for a token
539+
recorder = httptest.NewRecorder()
536540
tokenReqBody := controller.TokenRequest{
537541
GrantType: "authorization_code",
538542
Code: code,
@@ -559,7 +563,7 @@ func TestOIDCController(t *testing.T) {
559563
hasher := sha256.New()
560564
hasher.Write([]byte("some-challenge"))
561565
codeChallenge := hasher.Sum(nil)
562-
codeChallengeEncoded := base64.URLEncoding.EncodeToString(codeChallenge)
566+
codeChallengeEncoded := base64.RawURLEncoding.EncodeToString(codeChallenge)
563567
reqBody := service.AuthorizeRequest{
564568
Scope: "openid",
565569
ResponseType: "code",
@@ -593,6 +597,7 @@ func TestOIDCController(t *testing.T) {
593597
assert.NotEmpty(t, code)
594598

595599
// Now exchange the code for a token
600+
recorder = httptest.NewRecorder()
596601
tokenReqBody := controller.TokenRequest{
597602
GrantType: "authorization_code",
598603
Code: code,
@@ -607,7 +612,7 @@ func TestOIDCController(t *testing.T) {
607612
req.SetBasicAuth("some-client-id", "some-client-secret")
608613
router.ServeHTTP(recorder, req)
609614

610-
assert.Equal(t, 200, recorder.Code)
615+
assert.Equal(t, 400, recorder.Code)
611616
},
612617
},
613618
}

internal/controller/proxy_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
)
1818

1919
func TestProxyController(t *testing.T) {
20+
tlog.NewTestLogger().Init()
2021
tempDir := t.TempDir()
2122

2223
authServiceCfg := service.AuthServiceConfig{

internal/controller/resources_controller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import (
88

99
"github.com/gin-gonic/gin"
1010
"github.com/steveiliop56/tinyauth/internal/controller"
11+
"github.com/steveiliop56/tinyauth/internal/utils/tlog"
1112
"github.com/stretchr/testify/assert"
1213
"github.com/stretchr/testify/require"
1314
)
1415

1516
func TestResourcesController(t *testing.T) {
17+
tlog.NewTestLogger().Init()
1618
tempDir := t.TempDir()
1719

1820
resourcesControllerCfg := controller.ResourcesControllerConfig{

internal/controller/user_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
)
2323

2424
func TestUserController(t *testing.T) {
25+
tlog.NewTestLogger().Init()
2526
tempDir := t.TempDir()
2627

2728
authServiceCfg := service.AuthServiceConfig{

internal/controller/well_known_controller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import (
1313
"github.com/steveiliop56/tinyauth/internal/controller"
1414
"github.com/steveiliop56/tinyauth/internal/repository"
1515
"github.com/steveiliop56/tinyauth/internal/service"
16+
"github.com/steveiliop56/tinyauth/internal/utils/tlog"
1617
"github.com/stretchr/testify/assert"
1718
"github.com/stretchr/testify/require"
1819
)
1920

2021
func TestWellKnownController(t *testing.T) {
22+
tlog.NewTestLogger().Init()
2123
tempDir := t.TempDir()
2224

2325
oidcServiceCfg := service.OIDCServiceConfig{

0 commit comments

Comments
 (0)