Files
hmq/plugins/auth/authfile/acl_test.go
turtletramp 6be79cbe88 Bugfix - authfile plugin did wrongly use username as IP and IP as username in ACL checks (#100)
* adding test + fix issue with wrong order in acl check

* reduce to featureset from original fork
2020-12-02 10:05:46 +08:00

24 lines
533 B
Go

//+build test
package acl
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestOrigAcls(t *testing.T) {
pwd, _ := os.Getwd()
os.Chdir("../../../")
aclOrig := Init()
os.Chdir(pwd)
// rule: allow ip 127.0.0.1 2 $SYS/#
origAllowed := aclOrig.CheckACL(PUB, "dummyClientID", "dummyUser", "127.0.0.1", "$SYS/something")
assert.True(t, origAllowed)
origAllowed = aclOrig.CheckACL(SUB, "dummyClientID", "dummyUser", "127.0.0.1", "$SYS/something")
assert.False(t, origAllowed)
}