Skip to content

Commit eab6ac1

Browse files
authored
Merge pull request #59 from easysoft/sam/fix-for-unauthorized
Fix bug#64461
2 parents e8e4a15 + bbe30b3 commit eab6ac1

File tree

8 files changed

+18
-5
lines changed

8 files changed

+18
-5
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4
1+
3.4bug64461

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ztf",
33
"productName": "ztf",
4-
"version": "3.4",
4+
"version": "3.4bug64461",
55
"description": "ztf",
66
"main": ".webpack/main",
77
"scripts": {

client/src/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ztf",
33
"displayName": "ZTF",
4-
"version": "3.4",
4+
"version": "3.4bug64461",
55
"main": "./main.js",
66
"author": {
77
"name": "青岛易企天创管理咨询有限公司",
@@ -12,4 +12,4 @@
1212
"license": "GPL 3.0",
1313
"copyright": "Copyright (C) 2019-2022",
1414
"buildTime": "2022/04/18 09:01::01"
15-
}
15+
}

cmd/test/helper/http/http.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func GetCheckForward(url, token string) (ret []byte, isForward bool, err error)
3232

3333
if !strings.Contains(url, "/tokens") {
3434
req.Header.Add(commConsts.Token, token)
35+
req.Header.Add(commConsts.Cookie, "zentaosid="+commConsts.SessionId)
3536
}
3637

3738
resp, err := client.Do(req)
@@ -104,6 +105,7 @@ func PostOrPut(url, token string, method string, data interface{}) (ret []byte,
104105

105106
if !strings.Contains(url, "/tokens") {
106107
req.Header.Add(commConsts.Token, token)
108+
req.Header.Add(commConsts.Cookie, "zentaosid="+commConsts.SessionId)
107109
}
108110

109111
//req.Header.Set("Content-Type", "application/json")

internal/pkg/consts/var.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var (
3838

3939
ZenTaoVersion string
4040
Token = "Token"
41+
Cookie = "Cookie"
4142
SessionVar = "zentaosid"
4243
SessionId string
4344
RequestFix string

internal/pkg/helper/script/generator.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,14 @@ func generateTestStepAndScript(testSteps []commDomain.ZtfStep, steps *[]string,
125125

126126
// convert steps to nested
127127
for index := 0; index < len(testSteps); index++ {
128+
fmt.Printf("index=%d\n", index)
128129
ts := testSteps[index]
130+
fmt.Printf("ts=%v\n", ts)
129131
item := commDomain.ZtfStep{Desc: ts.Desc, Expect: ts.Expect, Children: make([]commDomain.ZtfStep, 0)}
130132

131133
if ts.Type == "group" {
132134
nestedSteps = append(nestedSteps, item)
133-
} else if ts.Type == "item" {
135+
} else if ts.Type == "item" && len(nestedSteps) > 0 {
134136
nestedSteps[len(nestedSteps)-1].Children = append(nestedSteps[len(nestedSteps)-1].Children, item)
135137
} else if ts.Type == "step" {
136138
nestedSteps = append(nestedSteps, item)

pkg/lib/common/utils.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ func IgnoreCodeFile(path string) bool {
129129
}
130130

131131
func AddSlashForUrl(url string) string {
132+
// 确保URL包含协议前缀
133+
if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") {
134+
url = "http://" + url
135+
}
136+
137+
// 确保URL以斜杠结尾
132138
if strings.LastIndex(url, "/") < len(url)-1 {
133139
url += "/"
134140
}

pkg/lib/http/http.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func GetCheckForward(url string) (ret []byte, isForward bool, err error) {
3636
} else {
3737
if !strings.Contains(url, "/tokens") {
3838
req.Header.Add(commConsts.Token, commConsts.SessionId)
39+
req.Header.Add(commConsts.Cookie, "zentaosid="+commConsts.SessionId)
3940
}
4041
}
4142

@@ -112,6 +113,7 @@ func PostOrPut(url string, method string, data interface{}) (ret []byte, err err
112113
} else {
113114
if !strings.Contains(url, "/tokens") {
114115
req.Header.Add(commConsts.Token, commConsts.SessionId)
116+
req.Header.Add(commConsts.Cookie, "zentaosid="+commConsts.SessionId)
115117
}
116118
}
117119

0 commit comments

Comments
 (0)