68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
# hobo - portal to configure and deploy applications
|
|
# Copyright (C) 2015-2019 Entr'ouvert
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU Affero General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from test_manager import login
|
|
|
|
from hobo.environment.models import Authentic, Variable
|
|
from hobo.franceconnect.views import PLATFORMS
|
|
|
|
|
|
def test_franceconnect(app, admin_user):
|
|
Authentic.objects.create(title='bar', slug='bar', base_url='http://bar.example.net')
|
|
login(app)
|
|
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC').count() == 0
|
|
|
|
response = app.get('/franceconnect/')
|
|
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC').count() == 0
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC_ENABLE', value='true').count() == 0
|
|
|
|
response = response.click('Enable')
|
|
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC').count() == 0
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC_ENABLE', value='true').count() == 0
|
|
|
|
response = response.form.submit().follow()
|
|
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC').count() == 1
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC_ENABLE', value='true').count() == 1
|
|
|
|
response.form.set('platform', 'prod')
|
|
response.form.set('client_id', 'xyz')
|
|
response.form.set('client_secret', '1234')
|
|
response = response.form.submit().follow()
|
|
|
|
assert Variable.objects.filter(name__startswith='SETTING_A2_FC').count() == 10
|
|
|
|
for key, value in PLATFORMS['prod'].items():
|
|
assert Variable.objects.filter(name='SETTING_' + key, value=value).count() == 1
|
|
|
|
assert Variable.objects.get(name='SETTING_A2_FC_USER_INFO_MAPPINGS').json == {
|
|
"last_name": {"ref": "family_name", "verified": True},
|
|
"first_name": {
|
|
"ref": "given_name",
|
|
"verified": True,
|
|
},
|
|
"title": {
|
|
"ref": "gender",
|
|
"translation": "simple",
|
|
"translation_simple": {"male": "Monsieur", "female": "Madame"},
|
|
"verified": True,
|
|
},
|
|
"email": "email",
|
|
}
|