-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #701 from nats-io/fix-sub-queue-perm-errors
[FIX] fixed an issue where permission errors related queue subscriptions was not properly notified to the client
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import { | |
assertArrayIncludes, | ||
assertEquals, | ||
assertRejects, | ||
assertStringIncludes, | ||
fail, | ||
} from "https://deno.land/[email protected]/assert/mod.ts"; | ||
import { | ||
|
@@ -1254,3 +1255,47 @@ Deno.test("auth - request context", async () => { | |
|
||
await cleanup(ns, nc, a); | ||
}); | ||
|
||
Deno.test("auth - sub permission queue", async () => { | ||
const conf = { | ||
authorization: { | ||
users: [{ | ||
user: "a", | ||
password: "a", | ||
permissions: { subscribe: ["q A"] }, | ||
}], | ||
}, | ||
}; | ||
|
||
const { ns, nc } = await setup(conf, { user: "a", pass: "a" }); | ||
|
||
const qA = deferred(); | ||
nc.subscribe("q", { | ||
queue: "A", | ||
callback: (err, msg) => { | ||
if (err) { | ||
qA.reject(err); | ||
} | ||
}, | ||
}); | ||
|
||
const qBad = deferred<NatsError>(); | ||
nc.subscribe("q", { | ||
queue: "bad", | ||
callback: (err, msg) => { | ||
if (err) { | ||
qBad.resolve(err); | ||
} | ||
}, | ||
}); | ||
await nc.flush(); | ||
|
||
const err = await qBad; | ||
qA.resolve(); | ||
|
||
await qA; | ||
|
||
assertEquals(err.code, ErrorCode.PermissionsViolation); | ||
assertStringIncludes(err.message, 'using queue "bad"'); | ||
await cleanup(ns, nc); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters