diff options
Diffstat (limited to 'spec/ban_spec.lua')
-rw-r--r-- | spec/ban_spec.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/ban_spec.lua b/spec/ban_spec.lua new file mode 100644 index 0000000..b990eda --- /dev/null +++ b/spec/ban_spec.lua @@ -0,0 +1,50 @@ +require("mineunit") + +mineunit("core") + +mineunit("common/chatcommands") +mineunit("server") +mineunit("player") +mineunit("settings") +mineunit("auth") + +sourcefile("init") + +mineunit:mods_loaded() +minetest.check_password_entry = function() + return false +end +minetest.kick_player = function () + return +end +local exists = minetest.player_exists +local settings = core.settings +describe("Afk works", function() + local admin = Player("admin", {kick = true, ban = true}) + local newplayer = Player("bannedplayer") + setup(function() + mineunit:execute_on_joinplayer(admin) + mineunit:execute_on_joinplayer(newplayer, {address = "9.9.9.9"}) + mineunit:execute_on_leaveplayer(newplayer) + end) + it("Bans players", function() + admin:send_chat_message("/xban bannedplayer ban message") + mineunit:execute_on_joinplayer(newplayer) + assert.is_not_true(newplayer._online) + end) + it("Bans players from the same IP", function() + local secondplayer = Player("totallynotbannedplayer") + mineunit:execute_on_joinplayer(secondplayer, {address = "9.9.9.9"}) + assert.is_not_true(newplayer._online) + end) + it("Unbans players", function() + admin:send_chat_message("/xunban bannedplayer unban message") + mineunit:execute_on_joinplayer(newplayer) + assert.is_true(newplayer._online) + end) + it("Allows players from the same IP again after unban", function() + local secondplayer = Player("totallynotbannedplayer") + mineunit:execute_on_joinplayer(secondplayer, {address = "9.9.9.9"}) + assert.is_true(newplayer._online) + end) +end) |