Skip to content

Commit e168f8e

Browse files
committed
Move credentialToStr and update it
1 parent 7263be2 commit e168f8e

File tree

5 files changed

+300
-71
lines changed

5 files changed

+300
-71
lines changed

lib/start-proxy-action.js

Lines changed: 117 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy.test.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -529,40 +529,6 @@ test.serial("getDownloadUrl returns matching release asset", async (t) => {
529529
});
530530
});
531531

532-
test.serial("credentialToStr - hides passwords", (t) => {
533-
const secret = "password123";
534-
const credential = {
535-
type: "maven_credential",
536-
password: secret,
537-
url: "https://localhost",
538-
};
539-
540-
const str = startProxyExports.credentialToStr(credential);
541-
542-
t.false(str.includes(secret));
543-
t.is(
544-
"Type: maven_credential; Host: undefined; Url: https://localhost Username: undefined; Password: true; Token: false",
545-
str,
546-
);
547-
});
548-
549-
test.serial("credentialToStr - hides tokens", (t) => {
550-
const secret = "password123";
551-
const credential = {
552-
type: "maven_credential",
553-
token: secret,
554-
url: "https://localhost",
555-
};
556-
557-
const str = startProxyExports.credentialToStr(credential);
558-
559-
t.false(str.includes(secret));
560-
t.is(
561-
"Type: maven_credential; Host: undefined; Url: https://localhost Username: undefined; Password: false; Token: true",
562-
str,
563-
);
564-
});
565-
566532
test.serial(
567533
"getSafeErrorMessage - returns actual message for `StartProxyError`",
568534
(t) => {

src/start-proxy.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -551,17 +551,6 @@ export async function getDownloadUrl(
551551
};
552552
}
553553

554-
/**
555-
* Pretty-prints a `Credential` value to a string, but hides the actual password or token values.
556-
*
557-
* @param c The credential to convert to a string.
558-
*/
559-
export function credentialToStr(c: Credential): string {
560-
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${
561-
c.username
562-
}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`;
563-
}
564-
565554
/**
566555
* Attempts to download a file from `url` into the toolcache.
567556
*

0 commit comments

Comments
 (0)