Restructure refimpl into go-lang and python subdirectories

Move Go reference implementation to refimpl/go-lang/ and add new
Python reference implementation in refimpl/python/. Update build.sh
with renamed draft and simplified tool paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 23:11:55 +01:00
parent ff795c72e6
commit bbf557e54b
52 changed files with 3972 additions and 341 deletions

View File

@@ -0,0 +1,56 @@
package ect
import (
"testing"
"time"
)
func TestJTICache_SeenAndAdd(t *testing.T) {
cache := NewJTICache(10, 1*time.Second)
if cache.Seen("jti-1") {
t.Error("unseen jti should not be seen")
}
cache.Add("jti-1")
if !cache.Seen("jti-1") {
t.Error("added jti should be seen")
}
if cache.Seen("jti-2") {
t.Error("other jti should not be seen")
}
cache.Add("jti-2")
if !cache.Seen("jti-2") {
t.Error("second jti should be seen")
}
}
func TestJTICache_Expiry(t *testing.T) {
cache := NewJTICache(10, 50*time.Millisecond)
cache.Add("jti-1")
if !cache.Seen("jti-1") {
t.Fatal("added jti should be seen")
}
time.Sleep(60 * time.Millisecond)
if cache.Seen("jti-1") {
t.Error("expired jti should not be seen")
}
}
func TestJTICache_MaxSizeEviction(t *testing.T) {
cache := NewJTICache(2, 5*time.Second)
cache.Add("jti-1")
cache.Add("jti-2")
cache.Add("jti-3") // evicts one
// At least one of jti-1, jti-2 may be evicted; jti-3 must be present
if !cache.Seen("jti-3") {
t.Error("newest jti should be present")
}
}
func TestJTICache_AddWhenAlreadyPresent(t *testing.T) {
cache := NewJTICache(2, 5*time.Second)
cache.Add("jti-1")
cache.Add("jti-1") // refresh same jti; should not evict
if !cache.Seen("jti-1") {
t.Error("jti-1 should still be present")
}
}