Exemplo n.º 1
0
def test_get_key_subjects_user_not_encrypted(mocker, config):
    """Nothing should be returned since it is disabled."""
    mocker.patch('cc.configuration.helpers.get_storage',
                 return_value={'type': 'bestdrive'})
    config.encryption_csp_settings = {}
    subjects = get_key_subjects(storage_id='blabla',
                                share_id=None,
                                config=config)
    assert subjects == ()
Exemplo n.º 2
0
def test_get_key_subjects_share_external_users_no_encrypt(mocker, config):
    """If a share is shared with externals and encrypt_external_shares is set."""
    config.encryption_csp_settings = {'gdruve': True}
    config.encrypt_external_shares = False
    config.shares_with_external_users = {('gdruve', 'ne_id')}
    config.master_key_subject = 'master:0:'

    mocker.patch('cc.configuration.helpers.get_storage',
                 return_value={'type': 'gdruve'})
    assert () == get_key_subjects(storage_id='gang',
                                  share_id='ne_id',
                                  config=config)
Exemplo n.º 3
0
def test_get_key_subjects_share_id(mocker, config):
    """ only the share subject should be returned in that case """
    config.encryption_enabled = True

    config.encryption_csp_settings = {'bestdrive': True}
    config.master_key_subject = 'master:0:'
    mocker.patch('cc.configuration.helpers.get_storage',
                 return_value={'type': 'bestdrive'})

    subjects = get_key_subjects(storage_id='blabla',
                                share_id='hehhe',
                                config=config)
    assert subjects[1] == 'share:0:bestdrive+hehhe'
Exemplo n.º 4
0
def test_get_key_subjects_user(mocker, config):
    """ only the user subject should be returned in that case """
    config.encryption_enabled = True
    config.organization_id = 'pad'
    config.user_id = '*****@*****.**'
    config.encryption_csp_settings = {'bestdrive': True}
    config.master_key_subject = 'master:0:'
    mocker.patch('cc.configuration.helpers.get_storage',
                 return_value={'type': 'bestdrive'})
    subjects = get_key_subjects(storage_id='blabla',
                                share_id=None,
                                config=config)
    assert subjects[1] == 'user:0:[email protected]@pad'
Exemplo n.º 5
0
def test_get_key_subjects_sp_enabled_globally_not(mocker, config):
    """Test if global disable return no keys."""
    config.encryption_csp_settings = {'gdruve': True}
    config.encryption_enabled = False
    config.encrypt_external_shares = False
    config.shares_with_external_users = set()
    config.master_key_subject = 'master:0:'

    mocker.patch('cc.configuration.helpers.get_storage',
                 return_value={'type': 'gdruve'})

    subjects = get_key_subjects(storage_id='gang',
                                share_id='ne_id',
                                config=config)
    assert subjects == ()