mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Fixed wrong logic to cover disallow all external domains use case.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
<template>
|
||||
<v-form ref="vFormRef">
|
||||
<v-switch
|
||||
v-model="model.bypass_virus_checks"
|
||||
:label="$gettext('Bypass virus checks')"
|
||||
/>
|
||||
</v-form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const model = defineModel()
|
||||
|
||||
const vFormRef = ref()
|
||||
|
||||
defineExpose({
|
||||
vFormRef,
|
||||
})
|
||||
</script>
|
||||
@@ -105,7 +105,7 @@ def is_alias_target_allowed(domain: str) -> bool:
|
||||
return False
|
||||
else:
|
||||
allowed_domains = params.get("alias_target_allow_list")
|
||||
if allowed_domains and domain not in convert_to_list(allowed_domains):
|
||||
if not allowed_domains or domain not in convert_to_list(allowed_domains):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -28,6 +28,18 @@ class AliasTargetSettingsTestCase(ModoAPITestCase):
|
||||
self.assertEqual(resp.status_code, 400)
|
||||
self.assertEqual(resp.json()["error"], "Target domain not allowed: bad.com")
|
||||
|
||||
def test_block_external_domains(self):
|
||||
self.set_global_parameter("alias_can_target_any_domain", False, app="admin")
|
||||
# Now try an external domain, should fail
|
||||
values = {
|
||||
"address": "list4@test.com",
|
||||
"recipients": ["user@bad.com"],
|
||||
"enabled": True,
|
||||
}
|
||||
resp = self.client.post(reverse("v2:alias-list"), values, format="json")
|
||||
self.assertEqual(resp.status_code, 400)
|
||||
self.assertEqual(resp.json()["error"], "Target domain not allowed: bad.com")
|
||||
|
||||
def test_allow_only_list_when_any_disallowed(self):
|
||||
# alias_can_target_any_domain = False and allow list contains domain
|
||||
self.set_global_parameter("alias_can_target_any_domain", False, app="admin")
|
||||
|
||||
Reference in New Issue
Block a user