Software /
code /
prosody
Annotate
plugins/mod_storage_none.lua @ 12579:ca6a43fe0231 0.12
util.jsonschema: Fix validation to not assume presence of "type" field
MattJ reported a curious issue where validation did not work as
expected. Primarily that the "type" field was expected to be mandatory,
and thus leaving it out would result in no checks being performed.
This was likely caused by misreading during initial development.
Spent some time testing against
https://github.com/json-schema-org/JSON-Schema-Test-Suite.git and
discovered a multitude of issues, far too many to bother splitting into
separate commits.
More than half of them fail. Many because of features not implemented,
which have been marked NYI. For example, some require deep comparisons
e.g. when objects or arrays are present in enums fields.
Some because of quirks with how Lua differs from JavaScript, e.g. no
distinct array or object types. Tests involving fractional floating
point numbers. We're definitely not going to follow references to remote
resources. Or deal with UTF-16 sillyness. One test asserted that 1.0 is
an integer, where Lua 5.3+ will disagree.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 08 Jul 2022 14:38:23 +0200 |
parent | 8061:ef671d337577 |
rev | line source |
---|---|
8058
1b35a562528d
mod_storage_none: Ignore unused arguments [luacheck]
Kim Alvefur <zash@zash.se>
parents:
6283
diff
changeset
|
1 -- luacheck: ignore 212 |
1b35a562528d
mod_storage_none: Ignore unused arguments [luacheck]
Kim Alvefur <zash@zash.se>
parents:
6283
diff
changeset
|
2 |
5425
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local driver = {}; |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local driver_mt = { __index = driver }; |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 |
6283
7cf6d3a2c855
mod_storage_{none,internal,sql}: Return error for unsupported (everything but keyval) store types
Kim Alvefur <zash@zash.se>
parents:
5425
diff
changeset
|
6 function driver:open(store, typ) |
8059
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
7 if typ and typ ~= "keyval" and typ ~= "archive" then |
6283
7cf6d3a2c855
mod_storage_{none,internal,sql}: Return error for unsupported (everything but keyval) store types
Kim Alvefur <zash@zash.se>
parents:
5425
diff
changeset
|
8 return nil, "unsupported-store"; |
7cf6d3a2c855
mod_storage_{none,internal,sql}: Return error for unsupported (everything but keyval) store types
Kim Alvefur <zash@zash.se>
parents:
5425
diff
changeset
|
9 end |
7cf6d3a2c855
mod_storage_{none,internal,sql}: Return error for unsupported (everything but keyval) store types
Kim Alvefur <zash@zash.se>
parents:
5425
diff
changeset
|
10 return setmetatable({ store = store, type = typ }, driver_mt); |
5425
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 end |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 function driver:get(user) |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 return {}; |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 end |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 function driver:set(user, data) |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 return nil, "Storage disabled"; |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 end |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 function driver:stores(username) |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 return { "roster" }; |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 function driver:purge(user) |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 return true; |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 end |
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 |
8059
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
28 function driver:append() |
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
29 return nil, "Storage disabled"; |
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
30 end |
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
31 |
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
32 function driver:find() |
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
33 return function () end, 0; |
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
34 end |
6a725b242804
mod_storage_none: Add allways empty archive storage
Kim Alvefur <zash@zash.se>
parents:
8058
diff
changeset
|
35 |
8061
ef671d337577
mod_storage_none: Add a noop archive delete method
Kim Alvefur <zash@zash.se>
parents:
8059
diff
changeset
|
36 function driver:delete() |
ef671d337577
mod_storage_none: Add a noop archive delete method
Kim Alvefur <zash@zash.se>
parents:
8059
diff
changeset
|
37 return true; |
ef671d337577
mod_storage_none: Add a noop archive delete method
Kim Alvefur <zash@zash.se>
parents:
8059
diff
changeset
|
38 end |
ef671d337577
mod_storage_none: Add a noop archive delete method
Kim Alvefur <zash@zash.se>
parents:
8059
diff
changeset
|
39 |
5425
b00812c6daf8
mod_storage_none: A null-like storage provider that returns all stores as empty, and fails to save anything to them
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 module:provides("storage", driver); |