Skip to content

Commit 920a4a4

Browse files
committed
Merge remote-tracking branch 'origin/master' into edge
2 parents 32f5bd3 + e5e869e commit 920a4a4

File tree

6 files changed

+61
-6
lines changed

6 files changed

+61
-6
lines changed

mig/install/MiGserver-template.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,5 +784,5 @@ logo_right = /images/skin/__SKIN__/logo-right.png
784784
#credits_text = 2003-2023, <a href="https://www.migrid.org">The MiG Project</a>
785785
#credits_image = /images/copyright.png
786786
# Optional data safety notice and popup on Files page
787-
#datasafety_link =
788-
#datasafety_text =
787+
datasafety_link = __DATASAFETY_LINK__
788+
datasafety_text = __DATASAFETY_TEXT__

mig/install/generateconfs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ def usage(options):
205205
'quota_backend',
206206
'ca_fqdn',
207207
'ca_user',
208-
'ca_smtp'
208+
'ca_smtp',
209+
'datasafety_link',
210+
'datasafety_text',
209211
]
210212
int_names = [
211213
'cert_valid_days',

mig/shared/install.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ def generate_confs(
498498
ca_fqdn='',
499499
ca_user='mig-ca',
500500
ca_smtp='localhost',
501+
datasafety_link='',
502+
datasafety_text='',
501503
_getpwnam=pwd.getpwnam,
502504
_prepare=None,
503505
_writefiles=None,
@@ -810,6 +812,8 @@ def _generate_confs_prepare(
810812
ca_fqdn,
811813
ca_user,
812814
ca_smtp,
815+
datasafety_link,
816+
datasafety_text,
813817
):
814818
"""Prepate conf generator run"""
815819
user_dict = {}
@@ -1056,6 +1060,8 @@ def _generate_confs_prepare(
10561060
user_dict['__CA_FQDN__'] = ca_fqdn
10571061
user_dict['__CA_USER__'] = ca_user
10581062
user_dict['__CA_SMTP__'] = ca_smtp
1063+
user_dict['__DATASAFETY_LINK__'] = datasafety_link
1064+
user_dict['__DATASAFETY_TEXT__'] = datasafety_text
10591065

10601066
user_dict['__MIG_USER__'] = "%s" % (options['user_uname'])
10611067
user_dict['__MIG_GROUP__'] = "%s" % (options['user_group'])

tests/fixture/confs-stdlocal/MiGserver.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,5 +784,5 @@ logo_right = /images/skin/migrid-basic/logo-right.png
784784
#credits_text = 2003-2023, <a href="https://www.migrid.org">The MiG Project</a>
785785
#credits_image = /images/copyright.png
786786
# Optional data safety notice and popup on Files page
787-
#datasafety_link =
788-
#datasafety_text =
787+
datasafety_link =
788+
datasafety_text =

tests/support.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ def fixturepath(relative_path):
273273
return tmp_path
274274

275275

276+
def outputpath(relative_path):
277+
assert not os.path.isabs(relative_path)
278+
tmp_path = os.path.join(TEST_OUTPUT_DIR, relative_path)
279+
return tmp_path
280+
281+
276282
def temppath(relative_path, test_case, skip_clean=False):
277283
assert isinstance(test_case, MigTestCase)
278284
tmp_path = os.path.join(TEST_OUTPUT_DIR, relative_path)

tests/test_mig_shared_install.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@
2727

2828
"""Unit tests for the migrid module pointed to in the filename"""
2929

30+
from past.builtins import basestring
3031
import binascii
32+
from configparser import ConfigParser, NoSectionError, NoOptionError
3133
import difflib
34+
import io
3235
import os
3336
import pwd
3437
import sys
3538

3639
sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
3740

3841
from support import MIG_BASE, TEST_OUTPUT_DIR, MigTestCase, \
39-
testmain, temppath, cleanpath, fixturepath, is_path_within
42+
testmain, temppath, cleanpath, fixturepath, is_path_within, outputpath
4043

4144
from mig.shared.defaults import keyword_auto
4245
from mig.shared.install import determine_timezone, generate_confs
@@ -113,6 +116,21 @@ class MigSharedInstall__generate_confs(MigTestCase):
113116
def before_each(self):
114117
self.output_path = TEST_OUTPUT_DIR
115118

119+
def assertConfigKey(self, generated, section, key, expected):
120+
if isinstance(generated, basestring):
121+
with io.open(generated) as config_file:
122+
generated = ConfigParser()
123+
generated.read_file(config_file)
124+
125+
try:
126+
actual = generated.get(section, key)
127+
except NoSectionError:
128+
raise AssertionError("no such section: %s" % (section,))
129+
except NoOptionError:
130+
raise AssertionError("on such option: %s in %s" % (key, section))
131+
132+
self.assertEqual(actual, expected)
133+
116134
def test_creates_output_directory_and_adds_active_symlink(self):
117135
symlink_path = temppath('confs', self)
118136
cleanpath('confs-foobar', self)
@@ -190,6 +208,29 @@ def capture_defaulted(*args, **kwargs):
190208
self.assertPathWithin(defaulted['mig_certs'], MIG_BASE)
191209
self.assertPathWithin(defaulted['mig_state'], MIG_BASE)
192210

211+
def test_creates_output_files_with_datasafety(self):
212+
fixture_dir = fixturepath("confs-stdlocal")
213+
expected_generated_dir = cleanpath('confs-stdlocal', self)
214+
symlink_path = temppath('confs', self)
215+
216+
generate_confs(
217+
self.output_path,
218+
destination=symlink_path,
219+
destination_suffix='-stdlocal',
220+
datasafety_link='TEST_DATASAFETY_LINK',
221+
datasafety_text='TEST_DATASAFETY_TEXT',
222+
_getpwnam=create_dummy_gpwnam(4321, 1234),
223+
)
224+
225+
relative_file = 'confs-stdlocal/MiGserver.conf'
226+
self.assertPathExists('confs-stdlocal/MiGserver.conf')
227+
228+
actual_file = outputpath(relative_file)
229+
self.assertConfigKey(
230+
actual_file, 'SITE', 'datasafety_link', expected='TEST_DATASAFETY_LINK')
231+
self.assertConfigKey(
232+
actual_file, 'SITE', 'datasafety_text', expected='TEST_DATASAFETY_TEXT')
233+
193234
def test_options_for_source_auto(self):
194235
options = generate_confs(
195236
'/some/arbitrary/path',

0 commit comments

Comments
 (0)