3825859da6
build / build (push) Successful in 2m20s
PP 增加受控凭据更新、真实登录与目录检查,待验证修改不会替换生效配置;扫描与取件共享生效修订。 钉钉来源向导、校验与登记共用 DWS 授权,支持中途恢复与换账号保护,取消旧扫码自动回落。 认证审计复用已有来源审计页,配置响应不回传密码;补齐运行镜像脚本与权限。 验证:make verify 退出 0;PP/DWS/httpapi 目标 race 回归通过;隔离 HTTP 服务验证 PP 协议及扫描/取件消费者。 尚未部署;真实 PP 凭据与目录可用性在测试站部署后验证。
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"context"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestPPAuthRoutesRequireAdminAndFailClosedWhenUnwired(t *testing.T) {
|
|
h, err := NewHandler(Config{Store: &fakeJobStore{}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, method := range []string{"GET", "PUT", "POST"} {
|
|
path := "/api/v1/pp-connection"
|
|
if method == "POST" {
|
|
path += "/test"
|
|
}
|
|
for _, role := range []string{"", roleViewer, roleEngineer, roleAdmin} {
|
|
req := httptest.NewRequest(method, path, nil)
|
|
if role != "" {
|
|
req = req.WithContext(context.WithValue(req.Context(), sessionKey{}, sessionIdentity{UserID: "admin", Username: "tester", Role: role, SessionID: "session"}))
|
|
}
|
|
req.Header.Set("X-Governance-Action", "pp-connection")
|
|
res := httptest.NewRecorder()
|
|
h.ServeHTTP(res, req)
|
|
want := 403
|
|
if role == "" {
|
|
want = 401
|
|
}
|
|
if role == roleAdmin {
|
|
want = 503
|
|
}
|
|
if res.Code != want {
|
|
t.Errorf("%s role=%q status=%d want=%d", method, role, res.Code, want)
|
|
}
|
|
}
|
|
if got := classifyRole(method, path); got != roleAdmin {
|
|
t.Errorf("%s classified=%q; credential metadata and tests must be admin only", method, got)
|
|
}
|
|
}
|
|
}
|