feat: Phase 1 — config, auth, OAuth2 PKCE, CLI scaffold, token store

This commit is contained in:
GoCalGoo
2026-04-01 21:25:49 +02:00
parent 514372fa6b
commit 10db895ada
14 changed files with 977 additions and 29 deletions

View File

@@ -0,0 +1,32 @@
package auth
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewPKCEChallenge(t *testing.T) {
p, err := NewPKCEChallenge()
require.NoError(t, err)
assert.NotEmpty(t, p.Verifier)
assert.NotEmpty(t, p.Challenge)
assert.Equal(t, "S256", p.Method)
assert.NotEqual(t, p.Verifier, p.Challenge)
}
func TestPKCEChallengeUniqueness(t *testing.T) {
p1, err := NewPKCEChallenge()
require.NoError(t, err)
p2, err := NewPKCEChallenge()
require.NoError(t, err)
assert.NotEqual(t, p1.Verifier, p2.Verifier)
assert.NotEqual(t, p1.Challenge, p2.Challenge)
}
func TestComputeChallenge(t *testing.T) {
verifier := "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
expected := "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"
assert.Equal(t, expected, computeChallenge(verifier))
}