<s> import pyuv <EOL> import pytest <EOL> from gaffer . gafferd . keys import ( KeyNotFound , KeyConflict , InvalidKey , <EOL> UnknownPermission , Key , DummyKey , KeyManager , SqliteKeyBackend ) <EOL> from test_http import MockConfig <EOL> def test_config ( ) : <EOL> return MockConfig ( auth_dbname = "<STR_LIT>" , keys_dbname = "<STR_LIT>" ) <EOL> def test_sqlite_backend ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with SqliteKeyBackend ( loop , conf ) as h : <EOL> h . set_key ( "<STR_LIT:test>" , { "<STR_LIT>" : { } } ) <EOL> with pytest . raises ( KeyConflict ) : <EOL> h . set_key ( "<STR_LIT:test>" , { "<STR_LIT>" : { } } ) <EOL> assert h . has_key ( "<STR_LIT:test>" ) == True <EOL> key = h . get_key ( "<STR_LIT:test>" ) <EOL> assert key == { "<STR_LIT:key>" : "<STR_LIT:test>" , "<STR_LIT>" : { } } <EOL> key = h . delete_key ( "<STR_LIT:test>" ) <EOL> with pytest . raises ( KeyNotFound ) : <EOL> key = h . get_key ( "<STR_LIT:test>" ) <EOL> h . set_key ( "<STR_LIT:test>" , { "<STR_LIT>" : { } } ) <EOL> h . set_key ( "<STR_LIT>" , { "<STR_LIT>" : { } } , "<STR_LIT:test>" ) <EOL> assert h . has_key ( "<STR_LIT>" ) == True <EOL> assert h . all_subkeys ( "<STR_LIT:test>" ) == [ { "<STR_LIT:key>" : "<STR_LIT>" , "<STR_LIT>" : { } } ] <EOL> assert len ( h . all_keys ( ) ) == <NUM_LIT:2> <EOL> assert h . all_keys ( ) == [ "<STR_LIT:test>" , "<STR_LIT>" ] <EOL> assert h . all_keys ( include_key = True ) == [ { "<STR_LIT:key>" : "<STR_LIT:test>" , <EOL> "<STR_LIT>" : { } } , { "<STR_LIT:key>" : "<STR_LIT>" , "<STR_LIT>" : { } } ] <EOL> def test_key_manager ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . set_key ( "<STR_LIT:test>" , { "<STR_LIT>" : { } } ) <EOL> with pytest . raises ( KeyConflict ) : <EOL> h . set_key ( "<STR_LIT:test>" , { "<STR_LIT>" : { } } ) <EOL> assert h . has_key ( "<STR_LIT:test>" ) == True <EOL> key = h . get_key ( "<STR_LIT:test>" ) <EOL> assert key == { "<STR_LIT:key>" : "<STR_LIT:test>" , "<STR_LIT>" : { } } <EOL> assert len ( h . _cache ) == <NUM_LIT:1> <EOL> assert "<STR_LIT:test>" in h . _cache <EOL> assert len ( h . _entries ) == <NUM_LIT:1> <EOL> assert list ( h . _entries ) == [ "<STR_LIT:test>" ] <EOL> key = h . delete_key ( "<STR_LIT:test>" ) <EOL> with pytest . raises ( KeyNotFound ) : <EOL> key = h . get_key ( "<STR_LIT:test>" ) <EOL> h . set_key ( "<STR_LIT:test>" , { "<STR_LIT>" : { } } ) <EOL> h . set_key ( "<STR_LIT>" , { "<STR_LIT>" : { } } , "<STR_LIT:test>" ) <EOL> assert h . has_key ( "<STR_LIT>" ) == True <EOL> assert h . all_subkeys ( "<STR_LIT:test>" ) == [ { "<STR_LIT:key>" : "<STR_LIT>" , "<STR_LIT>" : { } } ] <EOL> assert len ( h . all_keys ( ) ) == <NUM_LIT:2> <EOL> assert h . all_keys ( ) == [ "<STR_LIT:test>" , "<STR_LIT>" ] <EOL> assert h . all_keys ( include_key = True ) == [ { "<STR_LIT:key>" : "<STR_LIT:test>" , <EOL> "<STR_LIT>" : { } } , { "<STR_LIT:key>" : "<STR_LIT>" , "<STR_LIT>" : { } } ] <EOL> h . get_key ( "<STR_LIT:test>" ) <EOL> h . get_key ( "<STR_LIT>" ) <EOL> assert len ( h . _cache ) == <NUM_LIT:2> <EOL> assert "<STR_LIT:test>" in h . _cache <EOL> assert "<STR_LIT>" in h . _cache <EOL> assert len ( h . _entries ) == <NUM_LIT:2> <EOL> assert list ( h . _entries ) == [ "<STR_LIT:test>" , "<STR_LIT>" ] <EOL> h . delete_key ( "<STR_LIT:test>" ) <EOL> assert len ( h . _cache ) == <NUM_LIT:0> <EOL> assert len ( h . _entries ) == <NUM_LIT:0> <EOL> with pytest . raises ( KeyNotFound ) : <EOL> key = h . get_key ( "<STR_LIT:test>" ) <EOL> with pytest . raises ( KeyNotFound ) : <EOL> key = h . get_key ( "<STR_LIT>" ) <EOL> def test_create_key ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : True } , label = "<STR_LIT>" , key = "<STR_LIT:test>" ) <EOL> key = h . get_key ( "<STR_LIT:test>" ) <EOL> assert key == { "<STR_LIT:key>" : "<STR_LIT:test>" , "<STR_LIT:label>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { "<STR_LIT>" : True } } <EOL> def test_admin_permissions ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : True } , key = "<STR_LIT:test>" , label = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . label == "<STR_LIT>" <EOL> assert key . permissions == { "<STR_LIT>" : True } <EOL> assert key . is_admin ( ) == True <EOL> assert key . can_create_key ( ) == True <EOL> assert key . can_create_user ( ) == True <EOL> assert key . can_manage_all ( ) == True <EOL> assert key . can_read_all ( ) == True <EOL> assert key . can_write_all ( ) == True <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> def test_manage_all_permission ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:*>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . permissions == { "<STR_LIT>" : [ "<STR_LIT:*>" ] } <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == True <EOL> assert key . can_read_all ( ) == True <EOL> assert key . can_write_all ( ) == True <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> def test_read_all_permission ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:*>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . permissions == { "<STR_LIT>" : [ "<STR_LIT:*>" ] } <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == True <EOL> assert key . can_write_all ( ) == False <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_write_all_permission ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:*>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . permissions == { "<STR_LIT>" : [ "<STR_LIT:*>" ] } <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == True <EOL> assert key . can_write_all ( ) == True <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_manage_session ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:test>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == False <EOL> assert key . can_write_all ( ) == False <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT:test>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_manage_session2 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:test>" , "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == False <EOL> assert key . can_write_all ( ) == False <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> def test_manage_job ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_manage_job2 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> def test_manage_job3 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == True <EOL> def test_read_session ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:test>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == False <EOL> assert key . can_write_all ( ) == False <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_read_session1 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:test>" , "<STR_LIT>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == False <EOL> assert key . can_write_all ( ) == False <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_read_job ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_read_job2 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_read_job3 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_write_session ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:test>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == False <EOL> assert key . can_write_all ( ) == False <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT:test>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_write_session1 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:test>" , "<STR_LIT>" ] } , key = "<STR_LIT:test>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT:test>" ) ) <EOL> assert key . api_key == "<STR_LIT:test>" <EOL> assert key . is_admin ( ) == False <EOL> assert key . can_create_key ( ) == False <EOL> assert key . can_create_user ( ) == False <EOL> assert key . can_manage_all ( ) == False <EOL> assert key . can_read_all ( ) == False <EOL> assert key . can_write_all ( ) == False <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_write_job ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_write_job2 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_write_job3 ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> def test_mix ( ) : <EOL> conf = test_config ( ) <EOL> loop = pyuv . Loop . default_loop ( ) <EOL> with KeyManager ( loop , conf ) as h : <EOL> h . create_key ( { "<STR_LIT>" : [ "<STR_LIT:test>" ] , "<STR_LIT>" : [ "<STR_LIT>" ] } , key = "<STR_LIT>" ) <EOL> key = Key . load ( h . get_key ( "<STR_LIT>" ) ) <EOL> assert key . can_read ( "<STR_LIT:test>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_read ( "<STR_LIT>" ) == False <EOL> assert key . can_read ( "<STR_LIT>" ) == True <EOL> assert key . can_write ( "<STR_LIT:test>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == False <EOL> assert key . can_write ( "<STR_LIT>" ) == True <EOL> assert key . can_manage ( "<STR_LIT:test>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False <EOL> assert key . can_manage ( "<STR_LIT>" ) == False </s>
