Skip to content

Commit 57a47f4

Browse files
committed
Improve credentialToStr tests
1 parent 076d055 commit 57a47f4

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/start-proxy.test.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,20 +391,35 @@ test("getDownloadUrl returns matching release asset", async (t) => {
391391
t.is(info.url, "url-we-want");
392392
});
393393

394-
test("credentialToStr - hides passwords/tokens", (t) => {
394+
test("credentialToStr - hides passwords", (t) => {
395395
const secret = "password123";
396396
const credential = {
397397
type: "maven_credential",
398+
password: secret,
398399
};
399-
t.false(
400-
startProxyExports
401-
.credentialToStr({ password: secret, ...credential })
402-
.includes(secret),
400+
401+
const str = startProxyExports.credentialToStr(credential);
402+
403+
t.false(str.includes(secret));
404+
t.is(
405+
"Type: maven_credential; Host: undefined; Url: undefined Username: undefined; Password: true; Token: false",
406+
str,
403407
);
404-
t.false(
405-
startProxyExports
406-
.credentialToStr({ token: secret, ...credential })
407-
.includes(secret),
408+
});
409+
410+
test("credentialToStr - hides tokens", (t) => {
411+
const secret = "password123";
412+
const credential = {
413+
type: "maven_credential",
414+
token: secret,
415+
};
416+
417+
const str = startProxyExports.credentialToStr(credential);
418+
419+
t.false(str.includes(secret));
420+
t.is(
421+
"Type: maven_credential; Host: undefined; Url: undefined Username: undefined; Password: false; Token: true",
422+
str,
408423
);
409424
});
410425

0 commit comments

Comments
 (0)