Skip to content

Commit

Permalink
[LINT] linter/deprecations from Deno (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed May 16, 2023
1 parent 2338783 commit 17d3a76
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 36 deletions.
38 changes: 19 additions & 19 deletions tests/authenticator_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async function testAuthenticatorFn(
}

Deno.test("authenticator - username password fns", async () => {
let user = "a";
let pass = "a";
const user = "a";
const pass = "a";
const authenticator = usernamePasswordAuthenticator(() => {
return user;
}, () => {
Expand All @@ -105,7 +105,7 @@ Deno.test("authenticator - username password fns", async () => {
});

Deno.test("authenticator - username string password fn", async () => {
let pass = "a";
const pass = "a";
const authenticator = usernamePasswordAuthenticator("a", () => {
return pass;
});
Expand All @@ -121,7 +121,7 @@ Deno.test("authenticator - username string password fn", async () => {
});

Deno.test("authenticator - username fn password string", async () => {
let user = "a";
const user = "a";
const authenticator = usernamePasswordAuthenticator(() => {
return user;
}, "a");
Expand All @@ -137,7 +137,7 @@ Deno.test("authenticator - username fn password string", async () => {
});

Deno.test("authenticator - token fn", async () => {
let token = "tok";
const token = "tok";
const authenticator = tokenAuthenticator(() => {
return token;
});
Expand All @@ -151,8 +151,8 @@ Deno.test("authenticator - token fn", async () => {

Deno.test("authenticator - nkey fn", async () => {
const user = nkeys.createUser();
let seed = user.getSeed();
let nkey = user.getPublicKey();
const seed = user.getSeed();
const nkey = user.getPublicKey();

const authenticator = nkeyAuthenticator(() => {
return seed;
Expand All @@ -168,15 +168,15 @@ Deno.test("authenticator - nkey fn", async () => {

Deno.test("authenticator - jwt bearer fn", async () => {
const O = nkeys.createOperator();
let A = nkeys.createAccount();
let U = nkeys.createUser();
let ujwt = await encodeUser("U", U, A, { bearer_token: true });
const A = nkeys.createAccount();
const U = nkeys.createUser();
const ujwt = await encodeUser("U", U, A, { bearer_token: true });

const authenticator = jwtAuthenticator(() => {
return ujwt;
});

let resolver: Record<string, string> = {};
const resolver: Record<string, string> = {};
resolver[A.getPublicKey()] = await encodeAccount("A", A, {
limits: {
conn: -1,
Expand All @@ -194,9 +194,9 @@ Deno.test("authenticator - jwt bearer fn", async () => {

Deno.test("authenticator - jwt fn", async () => {
const O = nkeys.createOperator();
let A = nkeys.createAccount();
let U = nkeys.createUser();
let ujwt = await encodeUser("U", U, A, {});
const A = nkeys.createAccount();
const U = nkeys.createUser();
const ujwt = await encodeUser("U", U, A, {});

const authenticator = jwtAuthenticator(() => {
return ujwt;
Expand All @@ -222,16 +222,16 @@ Deno.test("authenticator - jwt fn", async () => {

Deno.test("authenticator - creds fn", async () => {
const O = nkeys.createOperator();
let A = nkeys.createAccount();
let U = nkeys.createUser();
let ujwt = await encodeUser("U", U, A, {});
let creds = fmtCreds(ujwt, U);
const A = nkeys.createAccount();
const U = nkeys.createUser();
const ujwt = await encodeUser("U", U, A, {});
const creds = fmtCreds(ujwt, U);

const authenticator = credsAuthenticator(() => {
return creds;
});

let resolver: Record<string, string> = {};
const resolver: Record<string, string> = {};
resolver[A.getPublicKey()] = await encodeAccount("A", A, {
limits: {
conn: -1,
Expand Down
16 changes: 8 additions & 8 deletions tests/helpers/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,31 @@ if (argv.h || argv.help) {
Deno.exit(0);
}

try {
const port = typeof argv.port === "number" ? argv.port : parseInt(argv.port);
const count = argv["count"] as number || 3;
const port = argv["port"] as number ?? 4222;

const base = {};
try {
const base = { debug: false };
const serverDebug = argv["server-debug"];
if (serverDebug) {
base.debug = true;
}

const cluster = argv.jetstream
? await NatsServer.jetstreamCluster(
argv.count,
count,
Object.assign(base, {
port,
jetstream: {
max_file_store: -1,
max_mem_store: -1,
},
}),
serverDebug,
base.debug,
)
: await NatsServer.cluster(
argv.count,
count,
Object.assign(base, { port }),
serverDebug,
base.debug,
);

cluster.forEach((s) => {
Expand Down
16 changes: 7 additions & 9 deletions tests/service_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ Deno.test("service - cross platform service test", async () => {
await nc.services.add(conf);

const args = [
"deno",
"run",
"-A",
"./tests/helpers/service-check.ts",
Expand All @@ -744,17 +743,16 @@ Deno.test("service - cross platform service test", async () => {
"demo.nats.io",
];

const p = Deno.run({ cmd: args, stderr: "piped", stdout: "piped" });
const [status, _stdout, stderr] = await Promise.all([
p.status(),
p.output(),
p.stderrOutput(),
]);
const cmd = new Deno.Command(Deno.execPath(), {
args,
stderr: "piped",
stdout: "piped",
});
const { success, stderr } = await cmd.output();

if (!status.success) {
if (!success) {
fail(StringCodec().decode(stderr));
}
p.close();

await nc.close();
});
Expand Down

0 comments on commit 17d3a76

Please sign in to comment.