bg5 commited on
Commit
8a8fe88
·
verified ·
1 Parent(s): 1737b0f

部署 zai2api 到 HF Space

Browse files
Files changed (3) hide show
  1. Dockerfile +0 -1
  2. deploy_hf_space.py +4 -7
  3. internal/captcha_test.go +0 -43
Dockerfile CHANGED
@@ -37,7 +37,6 @@ RUN cd /app/captcha-provider \
37
  && npm cache clean --force
38
 
39
  COPY --chown=node:node captcha-provider /app/captcha-provider
40
- COPY --chown=node:node .env /app/.env
41
  COPY --chown=node:node init.sh /app/init.sh
42
 
43
  RUN mkdir -p /app/data \
 
37
  && npm cache clean --force
38
 
39
  COPY --chown=node:node captcha-provider /app/captcha-provider
 
40
  COPY --chown=node:node init.sh /app/init.sh
41
 
42
  RUN mkdir -p /app/data \
deploy_hf_space.py CHANGED
@@ -47,15 +47,12 @@ def main() -> None:
47
  ".generated-auth-token.txt",
48
  "proxy-3000.js",
49
  ],
 
 
 
 
50
  commit_message="部署 zai2api 到 HF Space",
51
  )
52
- api.upload_file(
53
- repo_id=space_id,
54
- repo_type="space",
55
- path_or_fileobj=str(ROOT / ".env"),
56
- path_in_repo=".env",
57
- commit_message="上传 Space 环境配置",
58
- )
59
 
60
  api.add_space_secret(
61
  repo_id=space_id,
 
47
  ".generated-auth-token.txt",
48
  "proxy-3000.js",
49
  ],
50
+ delete_patterns=[
51
+ "internal/captcha_test.go",
52
+ "proxy-3000.js",
53
+ ],
54
  commit_message="部署 zai2api 到 HF Space",
55
  )
 
 
 
 
 
 
 
56
 
57
  api.add_space_secret(
58
  repo_id=space_id,
internal/captcha_test.go DELETED
@@ -1,43 +0,0 @@
1
- package internal
2
-
3
- import (
4
- "encoding/json"
5
- "net/http"
6
- "net/http/httptest"
7
- "testing"
8
- )
9
-
10
- func TestFetchCaptchaTokenPostsUpstreamJWT(t *testing.T) {
11
- const upstreamJWT = "header.payload.signature"
12
-
13
- srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
14
- if r.Method != http.MethodPost {
15
- t.Fatalf("method = %s, want POST", r.Method)
16
- }
17
- if r.URL.Path != "/token" {
18
- t.Fatalf("path = %s, want /token", r.URL.Path)
19
- }
20
- var body map[string]string
21
- if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
22
- t.Fatalf("decode body: %v", err)
23
- }
24
- if body["jwt_token"] != upstreamJWT {
25
- t.Fatalf("jwt_token = %q, want %q", body["jwt_token"], upstreamJWT)
26
- }
27
- w.Header().Set("Content-Type", "application/json")
28
- _, _ = w.Write([]byte(`{"ok":true,"captcha_verify_param":"captcha-token"}`))
29
- }))
30
- defer srv.Close()
31
-
32
- oldCfg := Cfg
33
- Cfg = &Config{CaptchaProviderURL: srv.URL}
34
- defer func() { Cfg = oldCfg }()
35
-
36
- token, err := fetchCaptchaToken(upstreamJWT)
37
- if err != nil {
38
- t.Fatalf("fetchCaptchaToken: %v", err)
39
- }
40
- if token != "captcha-token" {
41
- t.Fatalf("token = %q, want captcha-token", token)
42
- }
43
- }