Add another test
This commit is contained in:
parent
7151c3cefb
commit
00a83e49a1
|
|
@ -20,26 +20,30 @@ var (
|
||||||
Host: "b.com",
|
Host: "b.com",
|
||||||
Type: blacklisted,
|
Type: blacklisted,
|
||||||
}
|
}
|
||||||
|
rC = DomainRule{
|
||||||
|
Host: "d.c.com",
|
||||||
|
Type: blacklisted,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoadAndDump(t *testing.T) {
|
func TestLoadAndDump(t *testing.T) {
|
||||||
p, err := NewPolicyAuthorityDatabaseImpl(dbConnStr)
|
p, err := NewPolicyAuthorityDatabaseImpl(dbConnStr)
|
||||||
test.AssertNotError(t, err, "Couldn't create PADB")
|
test.AssertNotError(t, err, "Couldn't create PADB")
|
||||||
|
|
||||||
err = p.LoadRules([]DomainRule{rA, rB})
|
err = p.LoadRules([]DomainRule{rA, rB, rC})
|
||||||
test.AssertNotError(t, err, "Couldn't load rules")
|
test.AssertNotError(t, err, "Couldn't load rules")
|
||||||
|
|
||||||
r, err := p.DumpRules()
|
r, err := p.DumpRules()
|
||||||
test.AssertNotError(t, err, "Couldn't dump rules")
|
test.AssertNotError(t, err, "Couldn't dump rules")
|
||||||
|
|
||||||
test.AssertEquals(t, len(r), 2)
|
test.AssertEquals(t, len(r), 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
p, err := NewPolicyAuthorityDatabaseImpl(dbConnStr)
|
p, err := NewPolicyAuthorityDatabaseImpl(dbConnStr)
|
||||||
test.AssertNotError(t, err, "Couldn't create PADB")
|
test.AssertNotError(t, err, "Couldn't create PADB")
|
||||||
|
|
||||||
err = p.LoadRules([]DomainRule{rA, rB})
|
err = p.LoadRules([]DomainRule{rA, rB, rC})
|
||||||
test.AssertNotError(t, err, "Couldn't load rules")
|
test.AssertNotError(t, err, "Couldn't load rules")
|
||||||
|
|
||||||
err = p.CheckRules("b.com", false)
|
err = p.CheckRules("b.com", false)
|
||||||
|
|
@ -61,4 +65,7 @@ func TestGet(t *testing.T) {
|
||||||
test.AssertNotError(t, err, "Hostname should not be blacklisted")
|
test.AssertNotError(t, err, "Hostname should not be blacklisted")
|
||||||
err = p.CheckRules(".b.com", false)
|
err = p.CheckRules(".b.com", false)
|
||||||
test.AssertError(t, err, "Hostname should be blacklisted")
|
test.AssertError(t, err, "Hostname should be blacklisted")
|
||||||
|
|
||||||
|
err = p.CheckRules("e.d.c.com", false)
|
||||||
|
test.AssertError(t, err, "Hostname should be blacklisted")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue