Skip to content
Snippets Groups Projects
Select Git revision
  • 10e37c1780ee1280aef9b7f06ce59f9cd6c6ffce
  • master default protected
  • claims-in-idtoke
  • jwt_encode_inconsistencies
  • recovery-code-pwhash
  • incremental-sync
  • redis-rate-limits
  • typehints
  • v1.2.x
  • v1.x.x
  • v1.1.x
  • feature_invite_validuntil_minmax
  • Dockerfile
  • v1.0.x
  • roles-recursive-cte
  • v2.3.1
  • v2.3.0
  • v2.2.0
  • v2.1.0
  • v2.0.1
  • v2.0.0
  • v1.2.0
  • v1.1.2
  • v1.1.1
  • v1.0.2
  • v1.1.0
  • v1.0.1
  • v1.0.0
  • v0.3.0
  • v0.2.0
  • v0.1.5
  • v0.1.4
  • v0.1.2
33 results

test_ratelimit.py

Blame
  • Forked from uffd / uffd
    Source project has a limited visibility.
    test_services.py 1.73 KiB
    import datetime
    import unittest
    
    from flask import url_for
    
    # These imports are required, because otherwise we get circular imports?!
    from uffd import ldap, user
    
    from utils import dump, UffdTestCase
    
    class TestServices(UffdTestCase):
    	def setUpApp(self):
    		self.app.config['SERVICES'] = [
    			{
    				'title': 'Service Title',
    				'subtitle': 'Service Subtitle',
    				'description': 'Short description of the service as plain text',
    				'url': 'https://example.com/',
    				'logo_url': '/static/fairy-dust-color.png',
    				'required_group': 'users',
    				'permission_levels': [
    					{'name': 'Moderator', 'required_group': 'moderators'},
    					{'name': 'Admin', 'required_group': 'uffd_admin'},
    				],
    				'confidential': True,
    				'groups': [
    					{'name': 'Group "crew_crew"', 'required_group': 'users'},
    					{'name': 'Group "crew_logistik"', 'required_group': 'uffd_admin'},
    				],
    				'infos': [
    					{'title': 'Documentation', 'html': '<p>Some information about the service as html</p>', 'required_group': 'users'},
    				],
    				'links': [
    					{'title': 'Link to an external site', 'url': '#', 'required_group': 'users'},
    				],
    			},
    			{
    				'title': 'Minimal Service Title',
    			}
    		]
    		self.app.config['SERVICES_PUBLIC'] = True
    
    	def login(self):
    		self.client.post(path=url_for('session.login'),
    			data={'loginname': 'testuser', 'password': 'userpassword'}, follow_redirects=True)
    
    	def test_index(self):
    		r = self.client.get(path=url_for('services.index'))
    		dump('services_index_public', r)
    		self.assertEqual(r.status_code, 200)
    		self.assertNotIn(b'https://example.com/', r.data)
    		self.login()
    		r = self.client.get(path=url_for('services.index'))
    		dump('services_index', r)
    		self.assertEqual(r.status_code, 200)
    		self.assertIn(b'https://example.com/', r.data)