Software /
code /
prosody
Annotate
spec/util_bitcompat_spec.lua @ 12790:24b55f0e2db9 0.12
mod_http: Allow disabling CORS in the http_cors_override option and by default
Fixes #1779.
Due to an oversight in the logic, if the user set 'enabled' to false in an
override, it would disable the item's requested CORS settings, but still apply
Prosody's default CORS policy.
This change ensures that 'enabled = false' will now disable CORS entirely for
the requested item.
Due to the new structure of the code, it was necessary to have a flag to say
whether CORS is to be applied at all. Rather than hard-coding 'true' here, I
chose to add a new option: 'http_default_cors_enabled'. This is a boolean that
allows the operator to disable Prosody's default CORS policy entirely (the one
that is used when a module or config does not override it). This makes it
easier to disable CORS and then selectively enable it only on services you
want it on.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 31 Oct 2022 14:32:02 +0000 |
parent | 12366:c640717e01ca |
rev | line source |
---|---|
12366
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 describe("util.bitcompat", function () |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 -- bitcompat will pass through to an appropriate implementation. Our |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 -- goal here is to check that whatever implementation is in use passes |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 -- these basic sanity checks. |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local bit = require "util.bitcompat"; |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 it("bor works", function () |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 assert.equal(0xF0FF, bit.bor(0xF000, 0x00F0, 0x000F)); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 end); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 it("band works", function () |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 assert.equal(0x0F, bit.band(0xFF, 0x1F, 0x0F)); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 end); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 it("bxor works", function () |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 assert.equal(0x13, bit.bxor(0x10, 0x0F, 0x0C)); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 end); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 it("rshift works", function () |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 assert.equal(0x0F, bit.rshift(0xFF, 4)); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 it("lshift works", function () |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 assert.equal(0xFF00, bit.lshift(0xFF, 8)); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 end); |
c640717e01ca
util.bitcompat: Add some simple tests
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 end); |