# # # patch "std_hooks.lua" # from [f1e1322f6700dcd94def711edbf81a3d2668cd9f] # to [b8e68730f6c3b92ff68fb0e0f6f866f55b6cb20b] # # patch "tests/netsync_permissions/__driver__.lua" # from [00bc19e91496d8b9afe73532c94140df242764d2] # to [a0632f717c1fff69661ccc56516bcae93e3b3de8] # ============================================================ --- std_hooks.lua f1e1322f6700dcd94def711edbf81a3d2668cd9f +++ std_hooks.lua b8e68730f6c3b92ff68fb0e0f6f866f55b6cb20b @@ -1084,15 +1084,15 @@ function get_netsync_read_permitted(bran for j, val in pairs(item.values) do if val == "*" then return true end if val == "" and ident == nil then return true end - if val == ident.id then return true end - if globish_match(val, ident.name) then return true end + if ident ~= nil and val == ident.id then return true end + if ident ~= nil and globish_match(val, ident.name) then return true end end end elseif item.name == "deny" then if matches then for j, val in pairs(item.values) do if val == "*" then return false end if val == "" and ident == nil then return false end - if val == ident.id then return false end - if globish_match(val, ident.name) then return false end + if ident ~= nil and val == ident.id then return false end + if ident ~= nil and globish_match(val, ident.name) then return false end end end elseif item.name == "continue" then if matches then cont = true ============================================================ --- tests/netsync_permissions/__driver__.lua 00bc19e91496d8b9afe73532c94140df242764d2 +++ tests/netsync_permissions/__driver__.lua a0632f717c1fff69661ccc56516bcae93e3b3de8 @@ -13,6 +13,14 @@ genkey(keys.other) keys.other = "address@hidden" genkey(keys.other) +keys.byhash = "address@hidden" +genkey(keys.byhash) +check(mtn("ls", "keys"), 0, true) +check(grep(" address@hidden", "stdout"), 0, true) +line = readfile("stdout") +byhash_hash = string.sub(line, 0, 40) + + netsync.setup() -- test with open security settings @@ -101,9 +109,22 @@ check(mtn("automate", "get_revision", re check(mtn("automate", "get_revision", revs.unknown), 1, true, true) +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------------------------------------------------ -- test with closed security settings check(get("closed")) +-- setup by-hash line in permissions files +writeperm = readfile("closed/write-permissions") +writeperm = writeperm .. byhash_hash .. "\n" +writefile("closed/write-permissions", writeperm) + +readperm = readfile("closed/read-permissions") +readperm = readperm .. 'allow "' .. byhash_hash .. '"\n' +writefile("closed/read-permissions", readperm) + +-- general setup clean() writefile("_MTN/revision", "format_version \"1\"\n\n".. @@ -130,6 +151,13 @@ check(mtn2("automate", "get_revision", r srv:pull("testbranch") check(mtn2("automate", "get_revision", revs.base), 0, true, true) +-- pull with by-hash key + +clean(2) + +srv:pull({"testbranch", "--key", keys.byhash}) +check(mtn2("automate", "get_revision", revs.base), 0, true, true) + -- pull with bad branch fails clean(2) @@ -163,6 +191,14 @@ srv:push("testbranch") revs.default = base_revision() srv:push("testbranch") +-- push with by-hash key + +revert_to(revs.base, mtn2) +addfile("by-hash", "by-hash", mtn2) +check(mtn2("commit", "--message", "by-hash"), 0, false, false) +revs.other = base_revision() +srv:push({"testbranch", "--key", keys.byhash}, nil, 0) + -- push with other key revert_to(revs.base, mtn2)