<s> import pytest <EOL> from datetime import datetime <EOL> import json <EOL> import requests <EOL> from sondra . auth . application import Auth <EOL> from sondra . tests import api <EOL> BASE_URL = api . ConcreteSuite . url <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def suite ( request ) : <EOL> s = api . ConcreteSuite ( ) <EOL> Auth ( s ) <EOL> for app in s . values ( ) : <EOL> for coll in app . values ( ) : <EOL> coll . delete ( ) <EOL> return s <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def administrator ( request , suite ) : <EOL> suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create_user ( '<STR_LIT>' , password = '<STR_LIT:password>' , email = '<STR_LIT>' ) <EOL> u = suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> u [ '<STR_LIT>' ] = True <EOL> u . save ( conflict = '<STR_LIT:replace>' ) <EOL> def teardown ( ) : <EOL> u . delete ( ) <EOL> request . addfinalizer ( teardown ) <EOL> return suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def basic_user ( request , suite ) : <EOL> suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create_user ( '<STR_LIT>' , password = '<STR_LIT:password>' , email = '<STR_LIT>' ) <EOL> u = suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> u . save ( ) <EOL> def teardown ( ) : <EOL> u . delete ( ) <EOL> request . addfinalizer ( teardown ) <EOL> return u <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def application_level_user ( request , suite ) : <EOL> suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create_user ( username = '<STR_LIT>' , password = '<STR_LIT:password>' , email = '<STR_LIT>' ) <EOL> u = suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> r = suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create ( { <EOL> "<STR_LIT:title>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> } <EOL> ] <EOL> } ) <EOL> u [ '<STR_LIT>' ] = [ r ] <EOL> u . save ( ) <EOL> def teardown ( ) : <EOL> u . delete ( ) <EOL> request . addfinalizer ( teardown ) <EOL> return u <EOL> @ pytest . fixture ( scope = '<STR_LIT>' ) <EOL> def collection_level_user ( request , suite ) : <EOL> suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create_user ( '<STR_LIT>' , password = '<STR_LIT:password>' , email = '<STR_LIT>' ) <EOL> u = suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> r = suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] . create ( { <EOL> "<STR_LIT:title>" : "<STR_LIT>" , <EOL> "<STR_LIT:description>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> } <EOL> ] <EOL> } ) <EOL> u [ '<STR_LIT>' ] = [ r ] <EOL> u . save ( ) <EOL> def teardown ( ) : <EOL> u . delete ( ) <EOL> request . addfinalizer ( teardown ) <EOL> return u <EOL> def _login ( u ) : <EOL> login_result = requests . post ( '<STR_LIT>' , data = json . dumps ( { <EOL> "<STR_LIT:username>" : u [ '<STR_LIT:username>' ] , "<STR_LIT:password>" : "<STR_LIT:password>" <EOL> } ) ) <EOL> assert login_result . ok <EOL> wrapper = login_result . json ( ) <EOL> assert '<STR_LIT:_>' in wrapper <EOL> jwt = wrapper [ '<STR_LIT:_>' ] <EOL> return jwt <EOL> def _logout ( jwt ) : <EOL> logout_result = requests . post ( <EOL> '<STR_LIT>' , <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" + jwt } , <EOL> data = json . dumps ( { "<STR_LIT>" : jwt } ) ) <EOL> assert logout_result . ok <EOL> @ pytest . fixture <EOL> def admin_jwt ( request , administrator ) : <EOL> jwt = _login ( administrator ) <EOL> def teardown ( ) : <EOL> _logout ( jwt ) <EOL> request . addfinalizer ( teardown ) <EOL> @ pytest . fixture <EOL> def basic_jwt ( request , basic_user ) : <EOL> jwt = _login ( basic_user ) <EOL> def teardown ( ) : <EOL> _logout ( jwt ) <EOL> request . addfinalizer ( teardown ) <EOL> @ pytest . fixture <EOL> def collection_level_jwt ( request , collection_level_user ) : <EOL> jwt = _login ( administrator ) <EOL> def teardown ( ) : <EOL> _logout ( jwt ) <EOL> request . addfinalizer ( teardown ) <EOL> @ pytest . fixture <EOL> def app_level_jwt ( request , application_level_user ) : <EOL> jwt = _login ( administrator ) <EOL> def teardown ( ) : <EOL> _logout ( jwt ) <EOL> request . addfinalizer ( teardown ) <EOL> @ pytest . fixture <EOL> def docs ( ) : <EOL> return [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" . format ( x ) , "<STR_LIT:date>" : datetime . utcnow ( ) . isoformat ( ) } for x in range ( <NUM_LIT> ) <EOL> ] <EOL> def _call ( rel , jwt = None , data = None ) : <EOL> rel = '<STR_LIT>' + rel <EOL> if jwt : <EOL> if data : <EOL> result = requests . post ( rel , headers = _auth_header ( jwt ) , data = json . dumps ( data ) ) <EOL> else : <EOL> result = requests . get ( rel , headers = _auth_header ( jwt ) ) <EOL> else : <EOL> if data : <EOL> result = requests . post ( rel , data = json . dumps ( data ) ) <EOL> else : <EOL> result = requests . get ( rel ) <EOL> return result <EOL> def _auth_header ( jwt ) : <EOL> return { "<STR_LIT>" : "<STR_LIT>" + jwt } <EOL> def test_all_users ( suite , basic_user , application_level_user , collection_level_user ) : <EOL> assert len ( suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) == <NUM_LIT:3> <EOL> assert len ( suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) == <NUM_LIT:3> <EOL> assert len ( { cred [ '<STR_LIT:user>' ] for cred in suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] } ) == <NUM_LIT:3> <EOL> assert len ( { cred [ '<STR_LIT>' ] for cred in suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] } ) == <NUM_LIT:3> <EOL> basic_jwt = _login ( basic_user ) <EOL> application_level_jwt = _login ( application_level_user ) <EOL> collection_level_jwt = _login ( collection_level_user ) <EOL> assert len ( suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) == <NUM_LIT:3> <EOL> _logout ( basic_jwt ) <EOL> _logout ( application_level_jwt ) <EOL> _logout ( collection_level_jwt ) <EOL> def test_login_logout ( basic_user ) : <EOL> jwt = _login ( basic_user ) <EOL> result = requests . post ( '<STR_LIT>' , headers = _auth_header ( jwt ) ) <EOL> assert result . ok , result . text <EOL> _logout ( jwt ) <EOL> result = requests . post ( '<STR_LIT>' , headers = _auth_header ( jwt ) ) <EOL> assert not result . ok , "<STR_LIT>" <EOL> result = requests . post ( '<STR_LIT>' , data = json . dumps ( { <EOL> "<STR_LIT:username>" : "<STR_LIT>" , "<STR_LIT:password>" : "<STR_LIT>" <EOL> } ) ) <EOL> assert not result . ok <EOL> def test_renew ( basic_user ) : <EOL> jwt = _login ( basic_user ) <EOL> result = requests . post ( '<STR_LIT>' , data = json . dumps ( { "<STR_LIT>" : jwt } ) , headers = _auth_header ( jwt ) ) <EOL> assert result . ok , result . text <EOL> new_jwt = result . json ( ) [ '<STR_LIT:_>' ] <EOL> result = requests . get ( '<STR_LIT>' , headers = _auth_header ( jwt ) ) <EOL> assert not result . ok <EOL> result = requests . get ( '<STR_LIT>' , headers = _auth_header ( new_jwt ) ) <EOL> assert result . ok , result . text <EOL> _logout ( new_jwt ) <EOL> def test_signup ( suite ) : <EOL> result = _call ( '<STR_LIT>' , data = { <EOL> '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT:password>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } ) <EOL> assert result . ok , result . text <EOL> assert '<STR_LIT>' in suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> u = suite [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> assert u [ '<STR_LIT>' ] is False <EOL> assert u [ '<STR_LIT>' ] is False <EOL> result = _call ( '<STR_LIT>' , data = { <EOL> '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT:password>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } ) <EOL> assert not result . ok , "<STR_LIT>" <EOL> u . delete ( ) <EOL> def test_anonymous_meta ( ) : <EOL> result = requests . get ( '<STR_LIT>' ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' ) <EOL> assert result . ok , result . text <EOL> def test_admin_method_access ( suite , administrator ) : <EOL> jwt = _login ( administrator ) <EOL> headers = _auth_header ( jwt ) <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> _logout ( jwt ) <EOL> def test_admin_inheritor_documents ( suite , administrator , docs ) : <EOL> jwt = _login ( administrator ) <EOL> headers = _auth_header ( jwt ) <EOL> docs = [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" . format ( x ) , "<STR_LIT:date>" : datetime . utcnow ( ) . isoformat ( ) } for x in range ( <NUM_LIT> ) <EOL> ] <EOL> inheritor_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> post = requests . post ( inheritor_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> get_empty = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_empty . ok <EOL> _logout ( jwt ) <EOL> def test_admin_authenticated_documents ( suite , administrator , docs ) : <EOL> jwt = _login ( administrator ) <EOL> headers = _auth_header ( jwt ) <EOL> authenticated_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authenticated_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( authenticated_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) <EOL> def test_admin_authorized_documents ( suite , administrator , docs ) : <EOL> jwt = _login ( administrator ) <EOL> headers = _auth_header ( jwt ) <EOL> authorized_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authorized_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( authorized_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) <EOL> def test_basic_method_access ( suite , basic_user ) : <EOL> jwt = _login ( basic_user ) <EOL> headers = _auth_header ( jwt ) <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> _logout ( jwt ) <EOL> def test_basic_inheritor_documents ( suite , basic_user , docs ) : <EOL> jwt = _login ( basic_user ) <EOL> headers = _auth_header ( jwt ) <EOL> docs = [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" . format ( x ) , "<STR_LIT:date>" : datetime . utcnow ( ) . isoformat ( ) } for x in range ( <NUM_LIT> ) <EOL> ] <EOL> inheritor_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert not confirmed_dangerous_delete . ok <EOL> post = requests . post ( inheritor_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert not post . ok <EOL> get_all = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert not confirmed_dangerous_delete . ok <EOL> get_empty = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_empty . ok <EOL> _logout ( jwt ) <EOL> def test_basic_authenticated_documents ( suite , basic_user , docs ) : <EOL> jwt = _login ( basic_user ) <EOL> headers = _auth_header ( jwt ) <EOL> authenticated_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authenticated_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( authenticated_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) <EOL> def test_basic_authorized_documents ( suite , basic_user , docs ) : <EOL> jwt = _login ( basic_user ) <EOL> headers = _auth_header ( jwt ) <EOL> authorized_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert not confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authorized_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert not post . ok <EOL> get_all = requests . get ( authorized_documents + '<STR_LIT>' , headers = headers ) <EOL> assert not get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert not confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) <EOL> def test_application_user_method_access ( suite , application_level_user ) : <EOL> jwt = _login ( application_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> _logout ( jwt ) <EOL> def test_application_user_inheritor_documents ( suite , application_level_user , docs ) : <EOL> jwt = _login ( application_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> docs = [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" . format ( x ) , "<STR_LIT:date>" : datetime . utcnow ( ) . isoformat ( ) } for x in range ( <NUM_LIT> ) <EOL> ] <EOL> inheritor_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> post = requests . post ( inheritor_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> get_empty = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_empty . ok <EOL> _logout ( jwt ) <EOL> def test_application_user_authenticated_documents ( suite , application_level_user , docs ) : <EOL> jwt = _login ( application_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> authenticated_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authenticated_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( authenticated_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) <EOL> def test_application_user_authorized_documents ( suite , application_level_user , docs ) : <EOL> jwt = _login ( application_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> authorized_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert not confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authorized_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert not post . ok <EOL> get_all = requests . get ( authorized_documents + '<STR_LIT>' , headers = headers ) <EOL> assert not get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert not confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) <EOL> def test_collection_user_method_access ( suite , collection_level_user ) : <EOL> jwt = _login ( collection_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert result . ok , result . text <EOL> result = requests . get ( '<STR_LIT>' , headers = headers ) <EOL> assert not result . ok , result . text <EOL> _logout ( jwt ) <EOL> def test_collection_user_inheritor_documents ( suite , collection_level_user , docs ) : <EOL> jwt = _login ( collection_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> docs = [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" . format ( x ) , "<STR_LIT:date>" : datetime . utcnow ( ) . isoformat ( ) } for x in range ( <NUM_LIT> ) <EOL> ] <EOL> inheritor_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> post = requests . post ( inheritor_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( inheritor_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> get_empty = requests . get ( inheritor_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_empty . ok <EOL> _logout ( jwt ) <EOL> def test_collection_user_authenticated_documents ( suite , collection_level_user , docs ) : <EOL> jwt = _login ( collection_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> authenticated_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authenticated_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( authenticated_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authenticated_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) <EOL> def test_collection_user_authorized_documents ( suite , collection_level_user , docs ) : <EOL> jwt = _login ( collection_level_user ) <EOL> headers = _auth_header ( jwt ) <EOL> authorized_documents = '<STR_LIT>' <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : False } ) <EOL> assert not dangerous_delete . ok <EOL> post = requests . post ( authorized_documents , headers = headers , data = json . dumps ( docs ) ) <EOL> assert post . ok <EOL> get_all = requests . get ( authorized_documents + '<STR_LIT>' , headers = headers ) <EOL> assert get_all . ok <EOL> confirmed_dangerous_delete = requests . delete ( authorized_documents , headers = headers , params = { '<STR_LIT>' : True } ) <EOL> assert confirmed_dangerous_delete . ok <EOL> _logout ( jwt ) </s>
