Files
iceking2nd 20945777af
sdk-ci / test (push) Successful in 2m17s
sdk-release / release (push) Successful in 57s
sdk-release / cleanup (push) Successful in 5s
fix(sdk): 修复审计确认的 SDK-01~SDK-06/SDK-08 缺陷
- SDK-01:时钟回拨补偿只做一次(水位线跟随回拨后的时钟),避免 trustedNow 重复膨胀
- SDK-02:代理请求显式传 proxyAddr,消除运行期改写共享 opts 的数据竞争
- SDK-03:Decode 增加 256KB 结构层上限(与服务端 license 字节流上限对齐)
- SDK-04:修正 license key 熵注释为 80bit
- SDK-05:兼容服务端 version=0 空 CRL(携带吊销条目仍拒绝)
- SDK-06:Validate 状态显式枚举,UNKNOWN/空值给出明确 fail-closed 错误
- SDK-08:缓存密钥混合 0600 随机 secret(旧 HKDF(指纹) 缓存读取后自动迁移)
- SDK-07:README 记录 proxycert/Proxy 公钥旁路分发的设计信任假设
- 新增对应回归测试,go test -race -shuffle=on 全绿
2026-11-24 21:14:55 +08:00

43 lines
974 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package sdk
import (
"context"
"net/http"
"net/http/httptest"
"sync"
"testing"
)
// TestSDK02_NoRaceOnSharedRemoteServer 混合模式(远程 + 代理)下并发调用
// Activate 与 Refresh,不得改写共享 opts.remoteServer(-race 必须干净)。
func TestSDK02_NoRaceOnSharedRemoteServer(t *testing.T) {
e := newEnv(t)
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
}))
defer srv.Close()
c, err := New(
WithRemoteServer(srv.URL), WithProxy(srv.URL), WithSAToken("sa"),
WithLicenseKey("ef-KEY"), WithProductKey("prod_test"), WithTrustChain(e.trust()),
)
if err != nil {
t.Fatal(err)
}
c.actToken = "proxy-token"
var wg sync.WaitGroup
for range 20 {
wg.Add(2)
go func() {
defer wg.Done()
_ = c.Activate(context.Background(), "ef-KEY")
}()
go func() {
defer wg.Done()
_ = c.Refresh(context.Background())
}()
}
wg.Wait()
}