cityweb: set file read permission for group (#32517)

This commit is contained in:
Serghei Mihai 2019-04-23 10:06:02 +02:00
parent bc897a9fa9
commit f8d75cdc01
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import stat
from lxml import etree, objectify as xobject
from django.core.files.storage import default_storage
@ -384,4 +385,6 @@ class CivilStatusApplication(ComplexType):
os.makedirs(dirname)
with atomic_write(filepath) as fd:
fd.write(content)
# set read only permission for owner and group
os.chmod(filepath, stat.S_IRUSR|stat.S_IRGRP)
return filename

View File

@ -19,6 +19,7 @@ from __future__ import unicode_literals
import os
import json
import shutil
import stat
import pytest
import mock
@ -107,6 +108,8 @@ def test_demand_creation(app, setup, payload):
'evenement.interesse.mere.noms.nomDeFamille': 'Smith',
'evenement.interesse.mere.prenoms': 'Kim',
}
assert bool(os.stat(filename).st_mode & stat.S_IRUSR)
assert bool(os.stat(filename).st_mode & stat.S_IRGRP)
assert_xml_doc(filename, assertions)
elif 'mariage' in payload:
@ -138,6 +141,8 @@ def test_demand_creation(app, setup, payload):
'evenement.conjoint.mere.noms.nomDeFamille': 'Scaramucci',
'evenement.conjoint.mere.prenoms': 'Marguerite',
}
assert bool(os.stat(filename).st_mode & stat.S_IRUSR)
assert bool(os.stat(filename).st_mode & stat.S_IRGRP)
assert_xml_doc(filename, assertions)
else:
response = app.post_json(url, params=payload['death'])
@ -159,6 +164,8 @@ def test_demand_creation(app, setup, payload):
'evenement.dateEvenement.dateDebut': '2012-07-14',
'evenement.lieuEvenement.ville': 'Nancy',
}
assert bool(os.stat(filename).st_mode & stat.S_IRUSR)
assert bool(os.stat(filename).st_mode & stat.S_IRGRP)
assert_xml_doc(filename, assertions)