blob: b990edae663531b2abb683421198b03965a890fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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)
|