Require validated Credential for credentialToStr

This commit is contained in:
Michael B. Gale
2026-02-11 17:13:01 +00:00
parent 4d0bec12bf
commit bd36637537
2 changed files with 5 additions and 3 deletions

View File

@@ -396,13 +396,14 @@ test("credentialToStr - hides passwords", (t) => {
const credential = {
type: "maven_credential",
password: secret,
url: "https://localhost",
};
const str = startProxyExports.credentialToStr(credential);
t.false(str.includes(secret));
t.is(
"Type: maven_credential; Host: undefined; Url: undefined Username: undefined; Password: true; Token: false",
"Type: maven_credential; Host: undefined; Url: https://localhost Username: undefined; Password: true; Token: false",
str,
);
});
@@ -412,13 +413,14 @@ test("credentialToStr - hides tokens", (t) => {
const credential = {
type: "maven_credential",
token: secret,
url: "https://localhost",
};
const str = startProxyExports.credentialToStr(credential);
t.false(str.includes(secret));
t.is(
"Type: maven_credential; Host: undefined; Url: undefined Username: undefined; Password: false; Token: true",
"Type: maven_credential; Host: undefined; Url: https://localhost Username: undefined; Password: false; Token: true",
str,
);
});

View File

@@ -455,7 +455,7 @@ export async function getDownloadUrl(
*
* @param c The credential to convert to a string.
*/
export function credentialToStr(c: RawCredential): string {
export function credentialToStr(c: Credential): string {
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${
c.username
}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`;