Page MenuHomePhorge

D5313.1775335933.diff
No OneTemporary

Authored By
Unknown
Size
30 KB
Referenced Files
None
Subscribers
None

D5313.1775335933.diff

diff --git a/src/app/Http/Controllers/API/V4/PolicyController.php b/src/app/Http/Controllers/API/V4/PolicyController.php
--- a/src/app/Http/Controllers/API/V4/PolicyController.php
+++ b/src/app/Http/Controllers/API/V4/PolicyController.php
@@ -84,11 +84,13 @@
$policy_config['max_password_age'] = $config['max_password_age'];
// Get the mail delivery policies
- $mail_delivery_policy = [];
+ $mail_delivery_policy = ['greylist_policy'];
+ $policy_config['greylist_policy'] = $config['greylist_policy'];
+
if (config('app.with_mailfilter')) {
foreach (['itip_policy', 'externalsender_policy'] as $name) {
$mail_delivery_policy[] = $name;
- $policy_config[$name] = $config[$name] ?? null;
+ $policy_config[$name] = $config[$name];
}
}
diff --git a/src/app/Http/Controllers/API/V4/UsersController.php b/src/app/Http/Controllers/API/V4/UsersController.php
--- a/src/app/Http/Controllers/API/V4/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/UsersController.php
@@ -203,7 +203,7 @@
$response = $this->userResponse($user);
$response['skus'] = Entitlement::objectEntitlementsSummary($user);
- $response['config'] = $user->getConfig();
+ $response['config'] = $user->getConfig(true);
$response['aliases'] = $user->aliases()->pluck('alias')->all();
$code = $user->verificationcodes()->where('active', true)
diff --git a/src/app/Policy/Greylist.php b/src/app/Policy/Greylist.php
--- a/src/app/Policy/Greylist.php
+++ b/src/app/Policy/Greylist.php
@@ -4,6 +4,7 @@
use App\Policy\Greylist\Connect;
use App\Policy\Greylist\Whitelist;
+use App\Policy\Utils as PolicyUtils;
use App\Utils;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
@@ -129,7 +130,7 @@
// See if the recipient opted-out of the feature
$enabled = true;
if ($recipient) {
- $enabled = $recipient->getSetting('greylist_enabled') !== 'false';
+ $enabled = PolicyUtils::getPolicySetting($recipient, 'greylist_enabled');
}
// FIXME: Shouldn't we bail-out (return early) if there's no $recipient?
diff --git a/src/app/Policy/Mailfilter.php b/src/app/Policy/Mailfilter.php
--- a/src/app/Policy/Mailfilter.php
+++ b/src/app/Policy/Mailfilter.php
@@ -140,20 +140,8 @@
Modules\ExternalSenderModule::class => [],
];
- // Get user configuration (and policy if it is the account owner)
- $config = $user->getConfig();
-
- // Include account policy (if it is not the account owner)
- $wallet = $user->wallet();
- if ($wallet->user_id != $user->id) {
- $policy = array_filter(
- $wallet->owner->getConfig(),
- fn ($key) => str_contains($key, 'policy'),
- \ARRAY_FILTER_USE_KEY
- );
-
- $config = array_merge($config, $policy);
- }
+ // Get user configuration and account policy
+ $config = $user->getConfig(true);
foreach ($modules as $class => $module_config) {
$module = strtolower(str_replace('Module', '', class_basename($class)));
diff --git a/src/app/Policy/Password.php b/src/app/Policy/Password.php
--- a/src/app/Policy/Password.php
+++ b/src/app/Policy/Password.php
@@ -108,22 +108,6 @@
return $rules;
}
- /**
- * Parse configured policy string
- *
- * @param ?string $policy Policy specification
- *
- * @return array Policy specification as an array indexed by the policy rule type
- */
- public static function parsePolicy(?string $policy): array
- {
- $policy = explode(',', strtolower((string) $policy));
- $policy = array_map('trim', $policy);
- $policy = array_unique(array_filter($policy));
-
- return self::mapWithKeys($policy);
- }
-
/**
* Get the list of rules for a password
*
@@ -147,8 +131,8 @@
$conf = \config('app.password_policy');
}
- $supported = self::parsePolicy($supported);
- $conf = self::parsePolicy($conf);
+ $supported = Utils::parsePolicy($supported);
+ $conf = Utils::parsePolicy($conf);
$rules = $all ? $supported : $conf;
foreach ($rules as $idx => $rule) {
@@ -238,27 +222,4 @@
return $status;
}
-
- /**
- * Convert an array with password policy rules into one indexed by the rule name
- *
- * @param array $rules The rules list
- */
- private static function mapWithKeys(array $rules): array
- {
- $result = [];
-
- foreach ($rules as $rule) {
- $key = $rule;
- $value = null;
-
- if (strpos($key, ':')) {
- [$key, $value] = explode(':', $key, 2);
- }
-
- $result[$key] = $value;
- }
-
- return $result;
- }
}
diff --git a/src/app/Policy/Utils.php b/src/app/Policy/Utils.php
new file mode 100644
--- /dev/null
+++ b/src/app/Policy/Utils.php
@@ -0,0 +1,84 @@
+<?php
+
+namespace App\Policy;
+
+use App\User;
+
+class Utils
+{
+ /**
+ * Get user setting with a fallback to account policy
+ *
+ * @param User $user User to get the setting for
+ * @param string $name Setting name
+ */
+ public static function getPolicySetting(User $user, $name): bool|string
+ {
+ // Fallback default values for policies
+ // TODO: This probably should be configurable
+ $defaults = [
+ 'greylist_policy' => true,
+ ];
+
+ $policy_name = str_replace(['_enabled', '_config'], '_policy', $name);
+ $settings = $user->getSettings([$name, $policy_name]);
+
+ $value = $settings[$name] ?? null;
+
+ if ($value === null) {
+ $wallet = $user->wallet();
+
+ if ($wallet && $wallet->user_id != $user->id) {
+ $value = $wallet->owner->getSetting($policy_name);
+ } elseif (isset($settings[$policy_name])) {
+ $value = $settings[$policy_name];
+ }
+ }
+
+ if ($value === null && isset($defaults[$policy_name])) {
+ return $defaults[$policy_name];
+ }
+
+ // For now it's only bool settings, but it might be something else in the future
+ return $value === 'true';
+ }
+
+ /**
+ * Parse configured policy string
+ *
+ * @param ?string $policy Policy specification
+ *
+ * @return array Policy specification as an array indexed by the policy rule type
+ */
+ public static function parsePolicy(?string $policy): array
+ {
+ $policy = explode(',', strtolower((string) $policy));
+ $policy = array_map('trim', $policy);
+ $policy = array_unique(array_filter($policy));
+
+ return self::mapWithKeys($policy);
+ }
+
+ /**
+ * Convert an array with password policy rules into one indexed by the rule name
+ *
+ * @param array $rules The rules list
+ */
+ private static function mapWithKeys(array $rules): array
+ {
+ $result = [];
+
+ foreach ($rules as $rule) {
+ $key = $rule;
+ $value = null;
+
+ if (strpos($key, ':')) {
+ [$key, $value] = explode(':', $key, 2);
+ }
+
+ $result[$key] = $value;
+ }
+
+ return $result;
+ }
+}
diff --git a/src/app/Traits/UserConfigTrait.php b/src/app/Traits/UserConfigTrait.php
--- a/src/app/Traits/UserConfigTrait.php
+++ b/src/app/Traits/UserConfigTrait.php
@@ -3,19 +3,23 @@
namespace App\Traits;
use App\Policy\Password;
+use App\Policy\Utils as PolicyUtils;
use App\Utils;
trait UserConfigTrait
{
/**
* A helper to get the user configuration.
+ *
+ * @param bool $include_account_policies Get the policies options from the account owner
*/
- public function getConfig(): array
+ public function getConfig($include_account_policies = false): array
{
$settings = $this->getSettings([
'externalsender_config',
'externalsender_policy',
'greylist_enabled',
+ 'greylist_policy',
'guam_enabled',
'itip_config',
'itip_policy',
@@ -27,7 +31,8 @@
$config = [
'externalsender_config' => self::boolOrNull($settings['externalsender_config']),
'externalsender_policy' => $settings['externalsender_policy'] === 'true',
- 'greylist_enabled' => $settings['greylist_enabled'] !== 'false',
+ 'greylist_enabled' => self::boolOrNull($settings['greylist_enabled']),
+ 'greylist_policy' => $settings['greylist_policy'] !== 'false',
'guam_enabled' => $settings['guam_enabled'] === 'true',
'itip_config' => self::boolOrNull($settings['itip_config']),
'itip_policy' => $settings['itip_policy'] === 'true',
@@ -36,6 +41,19 @@
'password_policy' => $settings['password_policy'],
];
+ // If user is not an account owner read the policy from the owner config
+ if ($include_account_policies) {
+ $wallet = $this->wallet();
+ if ($wallet && $wallet->user_id != $this->id) {
+ $account_config = $wallet->owner->getConfig();
+ foreach (array_keys($config) as $name) {
+ if (str_contains($name, '_policy')) {
+ $config[$name] = $account_config[$name];
+ }
+ }
+ }
+ }
+
return $config;
}
@@ -51,9 +69,9 @@
$errors = [];
foreach ($config as $key => $value) {
- if (in_array($key, ['greylist_enabled', 'itip_policy', 'externalsender_policy'])) {
+ if (in_array($key, ['greylist_policy', 'itip_policy', 'externalsender_policy'])) {
$this->setSetting($key, $value ? 'true' : 'false');
- } elseif (in_array($key, ['itip_config', 'externalsender_config'])) {
+ } elseif (in_array($key, ['greylist_enabled', 'itip_config', 'externalsender_config'])) {
$this->setSetting($key, $value === null ? null : ($value ? 'true' : 'false'));
} elseif ($key == 'guam_enabled') {
$this->setSetting($key, $value ? 'true' : null);
@@ -119,7 +137,7 @@
return \trans('validation.invalid-password-policy');
}
- $systemPolicy = Password::parsePolicy(\config('app.password_policy'));
+ $systemPolicy = PolicyUtils::parsePolicy(\config('app.password_policy'));
// Min/Max values cannot exceed the system defaults, i.e. if system policy
// is min:5, user's policy cannot be set to a smaller number.
diff --git a/src/resources/lang/en/ui.php b/src/resources/lang/en/ui.php
--- a/src/resources/lang/en/ui.php
+++ b/src/resources/lang/en/ui.php
@@ -380,6 +380,10 @@
'calinvitations-text' => "Enables automated handling of calendar invitations in incoming email.",
'extsender' => "External sender warning",
'extsender-text' => "Adds a warning to every delivered message sent by an external sender.",
+ 'greylist' => "Greylisting",
+ 'greylist-text' => "Greylisting is a method of defending users against spam. Any incoming mail from an unrecognized sender "
+ . "is temporarily rejected. The originating server should try again after a delay. "
+ . "This time the email will be accepted. Spammers usually do not reattempt mail delivery.",
'mailDelivery' => "Mail delivery",
'password' => "Password",
'password-policy' => "Password Policy",
@@ -530,10 +534,6 @@
'finances' => "Finances",
'geolimit' => "Geo-lockin",
'geolimit-text' => "Defines a list of locations that are allowed for logon. You will not be able to login from a country that is not listed here.",
- 'greylisting' => "Greylisting",
- 'greylisting-text' => "Greylisting is a method of defending users against spam. Any incoming mail from an unrecognized sender "
- . "is temporarily rejected. The originating server should try again after a delay. "
- . "This time the email will be accepted. Spammers usually do not reattempt mail delivery.",
'imapproxy' => "IMAP proxy",
'imapproxy-text' => "Enables IMAP proxy that filters out non-mail groupware folders, so your IMAP clients do not see them.",
'list-title' => "User accounts",
diff --git a/src/resources/lang/fr/ui.php b/src/resources/lang/fr/ui.php
--- a/src/resources/lang/fr/ui.php
+++ b/src/resources/lang/fr/ui.php
@@ -295,6 +295,14 @@
. " Entrez le code que nous vous avons envoyé, ou cliquez sur le lien dans le message.",
],
+ 'policies' => [
+ 'greylist' => "Greylisting",
+ 'greylist-text' => "La greylisting est une méthode de défense des utilisateurs contre le spam."
+ . " Tout e-mail entrant provenant d'un expéditeur non reconnu est temporairement rejeté."
+ . " Le serveur d'origine doit réessayer après un délai cette fois-ci, le mail sera accepté."
+ . " Les spammeurs ne réessayent généralement pas de remettre le mail.",
+ ],
+
'resource' => [
'create' => "Créer une ressource",
'delete' => "Supprimer une ressource",
@@ -401,11 +409,6 @@
'email-aliases' => "Alias E-mail",
'ext-email' => "E-mail externe",
'finances' => "Finances",
- 'greylisting' => "Greylisting",
- 'greylisting-text' => "La greylisting est une méthode de défense des utilisateurs contre le spam."
- . " Tout e-mail entrant provenant d'un expéditeur non reconnu est temporairement rejeté."
- . " Le serveur d'origine doit réessayer après un délai cette fois-ci, le mail sera accepté."
- . " Les spammeurs ne réessayent généralement pas de remettre le mail.",
'list-title' => "Comptes d'utilisateur",
'list-empty' => "Il n'y a aucun utilisateur dans ce compte.",
'managed-by' => "Géré par",
diff --git a/src/resources/vue/Admin/User.vue b/src/resources/vue/Admin/User.vue
--- a/src/resources/vue/Admin/User.vue
+++ b/src/resources/vue/Admin/User.vue
@@ -208,7 +208,7 @@
<div class="card-text">
<form class="read-only short">
<div class="row plaintext">
- <label for="greylist_enabled" class="col-sm-4 col-form-label">{{ $t('user.greylisting') }}</label>
+ <label for="greylist_enabled" class="col-sm-4 col-form-label">{{ $t('policies.greylist') }}</label>
<div class="col-sm-8">
<span class="form-control-plaintext" id="greylist_enabled">
<span v-if="user.config.greylist_enabled" class="text-success">{{ $t('form.enabled') }}</span>
diff --git a/src/resources/vue/Policies.vue b/src/resources/vue/Policies.vue
--- a/src/resources/vue/Policies.vue
+++ b/src/resources/vue/Policies.vue
@@ -49,6 +49,15 @@
</div>
<div class="tab-pane" id="mailDelivery" role="tabpanel" aria-labelledby="tab-mailDelivery">
<form class="card-body" @submit.prevent="submitMailDelivery">
+ <div class="row checkbox mb-3">
+ <label for="greylist_policy" class="col-sm-4 col-form-label">{{ $t('policies.greylist') }}</label>
+ <div class="col-sm-8 pt-2">
+ <input type="checkbox" id="greylist_policy" name="greylist" value="1" class="form-check-input d-block mb-2" :checked="config.greylist_policy">
+ <small id="itip-hint" class="text-muted">
+ {{ $t('policies.greylist-text') }}
+ </small>
+ </div>
+ </div>
<div class="row checkbox mb-3">
<label for="itip_policy" class="col-sm-4 col-form-label">{{ $t('policies.calinvitations') }}</label>
<div class="col-sm-8 pt-2">
diff --git a/src/resources/vue/User/Info.vue b/src/resources/vue/User/Info.vue
--- a/src/resources/vue/User/Info.vue
+++ b/src/resources/vue/User/Info.vue
@@ -121,12 +121,16 @@
</template>
<template #maildelivery v-if="settingsSections.maildelivery">
<form @submit.prevent="submitMailDelivery">
- <div class="row checkbox mb-3">
- <label for="greylist_enabled" class="col-sm-4 col-form-label">{{ $t('user.greylisting') }}</label>
- <div class="col-sm-8 pt-2">
- <input type="checkbox" id="greylist_enabled" name="greylist_enabled" value="1" class="form-check-input d-block mb-2" :checked="user.config.greylist_enabled">
+ <div class="row mb-3">
+ <label for="greylist_enabled" class="col-sm-4 col-form-label">{{ $t('policies.greylist') }}</label>
+ <div class="col-sm-8">
+ <select id="greylist_enabled" name="greylist" class="form-select">
+ <option value="" :selected="user.config.greylist_enabled == null">{{ $t('form.default') }} ({{ $t(user.config.greylist_policy ? 'form.enabled' : 'form.disabled') }})</option>
+ <option value="true" :selected="user.config.greylist_enabled === true">{{ $t('form.enabled') }}</option>
+ <option value="false" :selected="user.config.greylist_enabled === false">{{ $t('form.disabled') }}</option>
+ </select>
<small id="greylisting-hint" class="text-muted">
- {{ $t('user.greylisting-text') }}
+ {{ $t('policies.greylist-text') }}
</small>
</div>
</div>
@@ -134,7 +138,7 @@
<label for="itip_config" class="col-sm-4 col-form-label">{{ $t('policies.calinvitations') }}</label>
<div class="col-sm-8">
<select id="itip_config" name="itip" class="form-select">
- <option value="" :selected="user.config.itip_config == null">{{ $t('form.default') }}</option>
+ <option value="" :selected="user.config.itip_config == null">{{ $t('form.default') }} ({{ $t(user.itip_policy ? 'form.enabled' : 'form.disabled') }})</option>
<option value="true" :selected="user.config.itip_config === true">{{ $t('form.enabled') }}</option>
<option value="false" :selected="user.config.itip_config === false">{{ $t('form.disabled') }}</option>
</select>
@@ -147,7 +151,7 @@
<label for="externalsender_config" class="col-sm-4 col-form-label">{{ $t('policies.extsender') }}</label>
<div class="col-sm-8">
<select id="externalsender_config" name="extsender" class="form-select">
- <option value="" :selected="user.config.externalsender_config == null">{{ $t('form.default') }}</option>
+ <option value="" :selected="user.config.externalsender_config == null">{{ $t('form.default') }} ({{ $t(user.config.externalsender_policy ? 'form.enabled' : 'form.disabled') }})</option>
<option value="true" :selected="user.config.externalsender_config === true">{{ $t('form.enabled') }}</option>
<option value="false" :selected="user.config.externalsender_config === false">{{ $t('form.disabled') }}</option>
</select>
@@ -521,12 +525,8 @@
const typeMap = { 'true': true, 'false': false }
let post = {}
- $('#maildelivery form').find('select,input[type=checkbox]').each(function() {
- if (this.nodeName == 'INPUT') {
- post[this.id] = this.checked ? 1 : 0
- } else {
- post[this.id] = typeMap[this.value] || null
- }
+ $('#maildelivery form').find('select').each(function() {
+ post[this.id] = this.value in typeMap ? typeMap[this.value] : null
})
axios.post('/api/v4/users/' + this.user_id + '/config', post)
@@ -556,8 +556,9 @@
this.$root.clearFormValidation($('#settings form'))
let post = this.$root.pick(this.user.config, ['limit_geo'])
+ const names = ['guam_enabled']
- ['guam_enabled'].forEach(name => {
+ names.forEach(name => {
if ($('#' + name).length) {
post[name] = $('#' + name).prop('checked') ? 1 : 0
}
diff --git a/src/tests/Browser/PoliciesTest.php b/src/tests/Browser/PoliciesTest.php
--- a/src/tests/Browser/PoliciesTest.php
+++ b/src/tests/Browser/PoliciesTest.php
@@ -18,6 +18,7 @@
$john->setSettings([
'itip_policy' => null,
'externalsender_policy' => null,
+ 'greylist_policy' => null,
]);
parent::tearDown();
@@ -140,6 +141,7 @@
$john->setSettings([
'itip_policy' => 'true',
'externalsender_policy' => null,
+ 'greylist_policy' => null,
]);
$this->browse(static function (Browser $browser) {
@@ -149,19 +151,23 @@
->assertSeeIn('#policies .nav-item:nth-child(2)', 'Mail delivery')
->click('#policies .nav-item:nth-child(2)')
->with('@maildelivery-form', static function (Browser $browser) {
- $browser->assertElementsCount('div.row', 2)
- ->assertSeeIn('div.row:nth-child(1) label', 'Calendar invitations')
+ $browser->assertElementsCount('div.row', 3)
+ ->assertSeeIn('div.row:nth-child(1) label', 'Greylisting')
->assertChecked('div.row:nth-child(1) input[type=checkbox]')
- ->assertSeeIn('div.row:nth-child(2) label', 'External sender warning')
- ->assertNotChecked('div.row:nth-child(2) input[type=checkbox]')
+ ->assertSeeIn('div.row:nth-child(2) label', 'Calendar invitations')
+ ->assertChecked('div.row:nth-child(2) input[type=checkbox]')
+ ->assertSeeIn('div.row:nth-child(3) label', 'External sender warning')
+ ->assertNotChecked('div.row:nth-child(3) input[type=checkbox]')
// Change the policy
->click('div.row:nth-child(1) input[type=checkbox]')
->click('div.row:nth-child(2) input[type=checkbox]')
+ ->click('div.row:nth-child(3) input[type=checkbox]')
->click('button[type=submit]');
})
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.');
});
+ $this->assertSame('false', $john->getSetting('greylist_policy'));
$this->assertSame('false', $john->getSetting('itip_policy'));
$this->assertSame('true', $john->getSetting('externalsender_policy'));
}
diff --git a/src/tests/Browser/SettingsTest.php b/src/tests/Browser/SettingsTest.php
--- a/src/tests/Browser/SettingsTest.php
+++ b/src/tests/Browser/SettingsTest.php
@@ -96,8 +96,7 @@
->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
->with('@settings', static function (Browser $browser) {
- $browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting')
- ->click('div.row:nth-child(1) input[type=checkbox]');
+ // This is tested in another place
})
->assertSeeIn('@nav #tab-personal', 'Personal information')
->click('@nav #tab-personal')
diff --git a/src/tests/Browser/UsersTest.php b/src/tests/Browser/UsersTest.php
--- a/src/tests/Browser/UsersTest.php
+++ b/src/tests/Browser/UsersTest.php
@@ -37,6 +37,7 @@
'phone' => '+1 509-248-1111',
'itip_config' => null,
'externalsender_config' => null,
+ 'greylist_policy' => null,
];
protected function setUp(): void
@@ -414,6 +415,7 @@
{
$john = $this->getTestUser('john@kolab.org');
$john->setSetting('greylist_enabled', null);
+ $john->setSetting('greylist_policy', null);
$john->setSetting('guam_enabled', null);
$john->setSetting('limit_geo', null);
$john->setSetting('externalsender_config', 'false');
@@ -429,14 +431,19 @@
->assertSeeIn('@setting-maildelivery-head', 'Mail delivery')
->with('@setting-maildelivery', static function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting')
- ->click('div.row:nth-child(1) input[type=checkbox]:checked')
+ ->assertSelectHasOptions('div.row:nth-child(1) select', ['', 'true', 'false'])
+ ->assertSelected('div.row:nth-child(1) select', '')
+ ->assertText('div.row:nth-child(1) select > option:nth-child(1)', 'default (enabled)')
+ ->select('div.row:nth-child(1) select', 'false')
->assertSeeIn('div.row:nth-child(2) label', 'Calendar invitations')
->assertSelectHasOptions('div.row:nth-child(2) select', ['', 'true', 'false'])
->assertSelected('div.row:nth-child(2) select', '')
+ ->assertText('div.row:nth-child(2) select > option:nth-child(1)', 'default (disabled)')
->select('div.row:nth-child(2) select', 'true')
->assertSeeIn('div.row:nth-child(3) label', 'External sender warning')
->assertSelectHasOptions('div.row:nth-child(3) select', ['', 'true', 'false'])
->assertSelected('div.row:nth-child(3) select', 'false')
+ ->assertText('div.row:nth-child(3) select > option:nth-child(1)', 'default (disabled)')
->select('div.row:nth-child(3) select', '')
->click('button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.');
diff --git a/src/tests/Feature/Controller/PolicyTest.php b/src/tests/Feature/Controller/PolicyTest.php
--- a/src/tests/Feature/Controller/PolicyTest.php
+++ b/src/tests/Feature/Controller/PolicyTest.php
@@ -216,7 +216,7 @@
$jack = $this->getTestUser('jack@kolab.org');
$john = $this->getTestUser('john@kolab.org');
- $john->settings()->whereIn('key', ['itip_policy', 'externalsender_policy'])->delete();
+ $john->settings()->whereIn('key', ['itip_policy', 'externalsender_policy', 'greylist_policy'])->delete();
// Unauth access not allowed
$response = $this->get('/api/v4/policies');
@@ -233,7 +233,8 @@
$response->assertStatus(200);
- $this->assertCount(0, $json['mailDelivery']);
+ $this->assertSame(['greylist_policy'], $json['mailDelivery']);
+ $this->assertTrue($json['config']['greylist_policy']);
// Get polcies when mailfilter is enabled
\config(['app.with_mailfilter' => true]);
@@ -243,8 +244,9 @@
$response->assertStatus(200);
- $this->assertSame(['itip_policy', 'externalsender_policy'], $json['mailDelivery']);
+ $this->assertSame(['greylist_policy', 'itip_policy', 'externalsender_policy'], $json['mailDelivery']);
$this->assertFalse($json['config']['itip_policy']);
+ $this->assertTrue($json['config']['greylist_policy']);
$this->assertTrue($json['config']['externalsender_policy']);
}
diff --git a/src/tests/Feature/Controller/UsersTest.php b/src/tests/Feature/Controller/UsersTest.php
--- a/src/tests/Feature/Controller/UsersTest.php
+++ b/src/tests/Feature/Controller/UsersTest.php
@@ -303,7 +303,7 @@
$this->assertSame($userA->email, $json['email']);
$this->assertTrue(is_array($json['statusInfo']));
$this->assertTrue(is_array($json['settings']));
- $this->assertTrue($json['config']['greylist_enabled']);
+ $this->assertNull($json['config']['greylist_enabled']);
$this->assertFalse($json['config']['guam_enabled']);
$this->assertSame([], $json['skus']);
$this->assertSame([], $json['aliases']);
diff --git a/src/tests/Feature/UserTest.php b/src/tests/Feature/UserTest.php
--- a/src/tests/Feature/UserTest.php
+++ b/src/tests/Feature/UserTest.php
@@ -565,7 +565,7 @@
$user->setSetting('limit_geo', null);
// greylist_enabled
- $this->assertTrue($user->getConfig()['greylist_enabled']);
+ $this->assertNull($user->getConfig()['greylist_enabled']);
$result = $user->setConfig(['greylist_enabled' => false, 'unknown' => false]);
@@ -674,6 +674,15 @@
$this->assertSame([], $result);
$this->assertSame(['US', 'CH'], $user->getConfig()['limit_geo']);
$this->assertSame('["US","CH"]', $user->getSetting('limit_geo'));
+
+ // Test getting account owner policies
+ $userB = $this->getTestUser('UserAccountB@UserAccount.com');
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $user->assignPackage($package_kolab, $userB);
+ $user->setConfig(['greylist_policy' => false]);
+
+ $this->assertTrue($userB->getConfig()['greylist_policy']);
+ $this->assertFalse($userB->getConfig(true)['greylist_policy']);
}
/**

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 8:52 PM (1 h, 50 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18791075
Default Alt Text
D5313.1775335933.diff (30 KB)

Event Timeline