Пример #1
0
func (s *filteringUnitTests) TestMatchSubnet(c *gc.C) {

	match, ok, err := client.MatchSubnet([]string{"localhost"}, "127.0.0.1")
	c.Check(err, jc.ErrorIsNil)
	c.Check(ok, jc.IsTrue)
	c.Check(match, jc.IsTrue)

	match, ok, err = client.MatchSubnet([]string{"127.0.0.1"}, "127.0.0.1")
	c.Check(err, jc.ErrorIsNil)
	c.Check(ok, jc.IsTrue)
	c.Check(match, jc.IsTrue)

	match, ok, err = client.MatchSubnet([]string{"localhost"}, "10.0.0.1")
	c.Check(err, jc.ErrorIsNil)
	c.Check(ok, jc.IsTrue)
	c.Check(match, jc.IsFalse)
}
Пример #2
0
func (s *filteringUnitTests) TestMatchSubnet(c *gc.C) {

	// We do not resolve hostnames.
	match, ok, err := client.MatchSubnet([]string{"localhost"}, "127.0.0.1")
	c.Check(err, jc.ErrorIsNil)
	c.Check(ok, jc.IsFalse)
	c.Check(match, jc.IsFalse)

	match, ok, err = client.MatchSubnet([]string{"127.0.0.1"}, "127.0.0.1")
	c.Check(err, jc.ErrorIsNil)
	c.Check(ok, jc.IsTrue)
	c.Check(match, jc.IsTrue)

	match, ok, err = client.MatchSubnet([]string{"localhost"}, "10.0.0.1")
	c.Check(err, jc.ErrorIsNil)
	c.Check(ok, jc.IsFalse)
	c.Check(match, jc.IsFalse)

	match, ok, err = client.MatchSubnet([]string{"testing.local"}, "testing.local")
	c.Check(err, jc.ErrorIsNil)
	c.Check(ok, jc.IsTrue)
	c.Check(match, jc.IsTrue)
}