Пример #1
0
    def test_SameAliasOnTwoVhosts(self):
        config_str="""
[{
  "hostname": "$default",
  "aliases": "a,b,c,d,e",
  "groups": {
    "$default": {
      "maxSessions": 1
    }
  }
},
{
  "hostname": "doshormigas",
  "aliases": "i,h,g,f,e",
  "groups": {
    "$default": {
      "maxSessions": 1
    }
  }
}]
"""
        manager = MockPolicyManager()
        policy = PolicyLocal(manager)
        ruleset = json.loads(config_str)
        denied = False
        try:
            policy.create_ruleset(ruleset[0])
            policy.create_ruleset(ruleset[1])
        except PolicyError as e:
            denied = True
        self.assertTrue(denied, "Rulesets duplicate same alias in two vhosts but condition not detected.")
Пример #2
0
    def test_AliasConflictsWithVhost(self):
        config_str="""
[{
  "hostname": "$default",
  "groups": {
    "$default": {
      "maxSessions": 1
    }
  }
},
{
  "hostname": "conflict-with-vhost",
  "aliases": "$default",
  "groups": {
    "$default": {
      "maxSessions": 1
    }
  }
}]
"""
        manager = MockPolicyManager()
        policy = PolicyLocal(manager)
        ruleset = json.loads(config_str)
        denied = False
        try:
            policy.create_ruleset(ruleset[0])
            policy.create_ruleset(ruleset[1])
        except PolicyError as e:
            denied = True
        self.assertTrue(denied, "Ruleset alias names other vhost but condition not detected.")
Пример #3
0
    def test_AliasesRenameOwnVhost(self):
        config_str="""
[{
  "hostname": "$default",
  "allowUnknownUser": true,
  "aliases": "$default",
  "groups": {
    "$default": {
      "remoteHosts": "*",
      "allowDynamicSource": true,
      "allowAnonymousSender": true,
      "sources": "$management, examples, q1",
      "targets": "$management, examples, q1",
      "maxSessions": 1
    }
  }
}]
"""
        manager = MockPolicyManager()
        policy = PolicyLocal(manager)
        ruleset = json.loads(config_str)
        denied = False
        try:
            policy.create_ruleset(ruleset[0])
        except PolicyError:
            denied = True
        self.assertTrue(denied, "Ruleset duplicates vhost and alias but condition not detected.")