Comparison

spec/util_pubsub_spec.lua @ 9840:ec353524b739 0.11

util.pubsub: Validate node configuration on node creation (fixes #1328)
author Kim Alvefur <zash@zash.se>
date Sun, 03 Mar 2019 19:31:56 +0100
parent 9816:7f84d7f77a00
child 10356:0a2d7efca039
comparison
equal deleted inserted replaced
9838:40ed04014b97 9840:ec353524b739
434 assert.is_true(ok); 434 assert.is_true(ok);
435 assert.same({ { node = "test", jid = "someone", subscription = true, } }, ret); 435 assert.same({ { node = "test", jid = "someone", subscription = true, } }, ret);
436 end); 436 end);
437 end); 437 end);
438 438
439 describe("node config checking", function ()
440 local service;
441 before_each(function ()
442 service = pubsub.new({
443 check_node_config = function (node, actor, config) -- luacheck: ignore 212
444 return config["max_items"] <= 20;
445 end;
446 });
447 end);
448
449 it("defaults, then configure", function ()
450 local ok, err = service:create("node", true);
451 assert.is_true(ok, err);
452
453 local ok, err = service:set_node_config("node", true, { max_items = 10 });
454 assert.is_true(ok, err);
455
456 local ok, err = service:set_node_config("node", true, { max_items = 100 });
457 assert.falsy(ok, err);
458 assert.equals(err, "not-acceptable");
459 end);
460
461 it("create with ok config, then configure", function ()
462 local ok, err = service:create("node", true, { max_items = 10 });
463 assert.is_true(ok, err);
464
465 local ok, err = service:set_node_config("node", true, { max_items = 100 });
466 assert.falsy(ok, err);
467
468 local ok, err = service:set_node_config("node", true, { max_items = 10 });
469 assert.is_true(ok, err);
470 end);
471
472 it("create with unacceptable config", function ()
473 local ok, err = service:create("node", true, { max_items = 100 });
474 assert.falsy(ok, err);
475 end);
476
477
478 end);
479
439 end); 480 end);