Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 3155c63

Browse files
authored
Merge branch 'main' into use-profile-name
2 parents 160a4df + 292c217 commit 3155c63

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

affiliation/identity.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ func (a *Affiliation) AddIdentity(identity *Identity) bool {
9292
queryParams["name"] = identity.Name
9393
queryParams["username"] = identity.Username
9494
queryParams["email"] = identity.Email
95-
queryParams["uuid"] = identity.UUID
9695
queryParams["id"] = identity.ID
96+
if identity.UUID != "" {
97+
queryParams["uuid"] = identity.UUID
98+
}
9799

98100
endpoint := a.AffBaseURL + "/affiliation/" + url.PathEscape(a.ProjectSlug) + "/add_identity/" + url.PathEscape(identity.Source)
99101
statusCode, res, err := a.httpClientProvider.Request(strings.TrimSpace(endpoint), "POST", headers, nil, queryParams)

uuid/uuid.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ func GenerateIdentity(source, email, name, username *string) (string, error) {
9494
args := make([]string, 4)
9595
args[0] = *source
9696

97-
if email == nil {
97+
if email == nil || *email == "" {
9898
args[1] = "none"
9999
} else {
100100
args[1] = *email
101101
}
102102

103-
if name == nil {
103+
if name == nil || *name == "" {
104104
args[2] = "none"
105105
} else {
106106
args[2] = *name
107107
}
108108

109-
if username == nil {
109+
if username == nil || *username == "" {
110110
args[3] = "none"
111111
} else {
112112
args[3] = *username

uuid/uuid_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,32 +172,32 @@ func testGenerateIdentity(t *testing.T) {
172172
{
173173
"test2",
174174
input{&testInput[1][0], &testInput[1][1], &testInput[1][2], &testInput[1][3]},
175-
"3f0eb1c38060ce3bc6cb1676c8b9660e99354291",
175+
"334da68fcd3da4e799791f73dfada2afb22648c6",
176176
},
177177
{
178178
"test3",
179179
input{&testInput[2][0], &testInput[2][1], &testInput[2][2], &testInput[2][3]},
180-
"a4b4591c3a2171710c157d7c278ea3cc03becf81",
180+
"3710e9f3f44e0434b36840fc39f5e9d1b421b081",
181181
},
182182
{
183183
"test4",
184184
input{&testInput[3][0], &testInput[3][1], &testInput[3][2], &testInput[3][3]},
185-
"76e3624e24aacae178d05352ad9a871dfaf81c13",
185+
"c7acd177d107a0aefa6718e2ff0dec6ceba71660",
186186
},
187187
{
188188
"test5",
189189
input{&testInput[4][0], &testInput[4][1], &testInput[4][2], &testInput[4][3]},
190-
"6e7ce2426673f8a23a72a343b1382dda84c0078b",
190+
"e38a553ae6f7e8096643bd8f22594b3577c4b14c",
191191
},
192192
{
193193
"test6",
194194
input{&testInput[5][0], &testInput[5][1], &testInput[5][2], &testInput[5][3]},
195-
"c88e126749ff006eb1eea25e4bb4c1c125185ed2",
195+
"7db54288c75a9906461f08a91b6895c1957bf38b",
196196
},
197197
{
198198
"test7",
199199
input{&testInput[6][0], &testInput[6][1], &testInput[6][2], &testInput[6][3]},
200-
"9a0498297d9f0b7e4baf3e6b3740d22d2257367c",
200+
"5542b4b2de803f6a6d347c1d21269f2020485678",
201201
},
202202
}
203203

@@ -257,7 +257,7 @@ func testCaseUnaccentName(t *testing.T) {
257257
inp = input{&inpStr[0], &inpStr[1], &inpStr[2], &inpStr[3]}
258258
unaccentResult, _ := GenerateIdentity(inp.source, inp.email, inp.name, inp.username)
259259
assert.Equal(t, accentResult, unaccentResult)
260-
assert.Equal(t, accentResult, "9a0498297d9f0b7e4baf3e6b3740d22d2257367c")
260+
assert.Equal(t, accentResult, "5542b4b2de803f6a6d347c1d21269f2020485678")
261261

262262
inpStr = []string{"scm", "", "Santiago Dueñas", ""}
263263
inp = input{&inpStr[0], &inpStr[1], &inpStr[2], &inpStr[3]}
@@ -266,7 +266,7 @@ func testCaseUnaccentName(t *testing.T) {
266266
inp = input{&inpStr[0], &inpStr[1], &inpStr[2], &inpStr[3]}
267267
unaccentResult, _ = GenerateIdentity(inp.source, inp.email, inp.name, inp.username)
268268
assert.Equal(t, accentResult, unaccentResult)
269-
assert.Equal(t, accentResult, "0f1dd18839007ee8a11d02572ca0a0f4eedaf2cd")
269+
assert.Equal(t, accentResult, "a0b8a9154c4327c917b31dd180b63b3696a27e31")
270270

271271
inpStr = []string{"scm", "", "Tomáš Čechvala", ""}
272272
inp = input{&inpStr[0], &inpStr[1], &inpStr[2], &inpStr[3]}
@@ -337,7 +337,6 @@ func testSpecialCasesIdentity(t *testing.T) {
337337
args = append(args, testCase.input...)
338338
legacyUUID, _ := execLegacyUUID(args...)
339339
uid, _ := GenerateIdentity(&testCase.input[0], &testCase.input[1], &testCase.input[2], &testCase.input[3])
340-
341340
assert.Equal(tt, legacyUUID, uid)
342341
})
343342
}

0 commit comments

Comments
 (0)