SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
test: stop comparing two JWTs minted a second apart (#10495)
Chris Luccf5dc34e906
diff --git a/weed/server/filer_server_handlers_proxy_test.go b/weed/server/filer_server_handlers_proxy_test.goindex 46c6fe18f2..d6babddade 100644--- a/weed/server/filer_server_handlers_proxy_test.go+++ b/weed/server/filer_server_handlers_proxy_test.go@@ -79,12 +79,6 @@ func (v *proxyTestVolume) requireReached(t *testing.T) {// header, so a caller-supplied one would outrank the token the filer attaches// on a read -- the credential the volume server evaluates has to be the filer's.func TestProxyReadDropsCallerJwtQueryParam(t *testing.T) {- minted := &FilerServer{volumeGuard: security.NewGuard([]string{}, proxyTestWriteKey, 10, proxyTestReadKey, 10)}- want := minted.maybeGetVolumeReadJwtAuthorizationToken(proxyTestFileId)- if want == "" {- t.Fatal("no read token minted despite a configured read key")- }-for _, method := range []string{http.MethodGet, http.MethodHead} {t.Run(method, func(t *testing.T) {volume := newProxyTestVolume(t)@@ -98,8 +92,19 @@ func TestProxyReadDropsCallerJwtQueryParam(t *testing.T) {if got := volume.seenEffectiveJwt(); got == "caller-supplied" {t.Fatal("caller's jwt query param outranked the filer-minted token")}- if got := volume.seenEffectiveJwt(); got != want {- t.Fatalf("volume server would evaluate %q, want the minted token %q", got, want)+ // The credential has to be a filer-minted read token for THIS file.+ // Comparing it against a separately minted token would also say that,+ // but only within the second that minted both: the expiry claim has+ // one-second resolution, so two mints either side of a tick differ in+ // the encoded string while carrying the same authority and file id.+ claims := &security.SeaweedFileIdClaims{}+ if _, err := security.DecodeJwt(security.SigningKey(proxyTestReadKey),+ security.EncodedJwt(volume.seenEffectiveJwt()), claims); err != nil {+ t.Fatalf("volume server would evaluate %q, which does not validate against the read key: %v",+ volume.seenEffectiveJwt(), err)+ }+ if claims.Fid != proxyTestFileId {+ t.Fatalf("token authorizes file %q, want %q", claims.Fid, proxyTestFileId)}if q := volume.seenRawQuery(); strings.Contains(q, "jwt=") {t.Fatalf("jwt survived in the forwarded query: %q", q)