Software /
code /
prosody
File
tools/generate_format_spec.lua @ 12658:7ca5645f46cd
usermanager: Remove concept of global authz provider
Rationale:
- Removes a bunch of code!
- We don't have many cases where an actor is not bound to one of our hosts
- A notable exception is the admin shell, but if we ever attempt to lock those
sessions down, there is a load of other work that also has to be done. And
it's not clear if we would need a global authz provider for that anyway.
- Removes an extra edge case from the necessary mental model for operators
- Sessions that aren't bound to a host generally are anonymous or have an
alternative auth model (such as by IP addres).
- With the encapsulation now provided by util.roles, ad-hoc "detached roles"
can still be created anyway by code that needs them.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 12 Aug 2022 16:21:57 +0100 |
parent | 12039:e0a8c5b1ab4f |
line wrap: on
line source
local format = require"util.format".format; local dump = require"util.serialization".new("oneline") local types = { "nil"; "boolean"; "number"; "string"; "function"; -- "userdata"; "thread"; "table"; }; local example_values = { ["nil"] = { n = 1; nil }; ["boolean"] = { true; false }; ["number"] = { 97; -12345; 1.5; 73786976294838206464; math.huge; 2147483647 }; ["string"] = { "hello"; "foo \1\2\3 bar"; "nödåtgärd"; string.sub("nödåtgärd", 1, -4) }; ["function"] = { function() end }; -- ["userdata"] = {}; ["thread"] = { coroutine.create(function() end) }; ["table"] = { {}, setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end}) }; }; local example_strings = setmetatable({ ["nil"] = { "nil" }; ["function"] = { "function() end" }; ["number"] = { "97"; "-12345"; "1.5"; "73786976294838206464"; "math.huge"; "2147483647" }; ["thread"] = { "coroutine.create(function() end)" }; ["table"] = { "{ }", "setmetatable({},{__tostring=function ()return \"foo \\1\\2\\3 bar\"end})" } }, { __index = function() return {} end }); for _, lua_type in ipairs(types) do print(string.format("\t\tdescribe(\"%s\", function ()", lua_type)); local examples = example_values[lua_type]; for fmt in ("cdiouxXaAeEfgGqs"):gmatch(".") do print(string.format("\t\t\tdescribe(\"to %%%s\", function ()", fmt)); print("\t\t\t\tit(\"works\", function ()"); for i = 1, examples.n or #examples do local example = examples[i]; if not tostring(example):match("%w+: 0[xX]%x+") then print(string.format("\t\t\t\t\tassert.equal(%q, format(%q, %s))", format("%" .. fmt, example), "%" .. fmt, example_strings[lua_type][i] or dump(example))); else print(string.format("\t\t\t\t\tassert.matches(\"[%s: 0[xX]%%x+]\", format(%q, %s))", lua_type, "%" .. fmt, example_strings[lua_type][i] or dump(example))); end end print("\t\t\t\tend);"); print("\t\t\tend);"); print() end print("\t\tend);"); print() end