Ejemplo n.º 1
0
def test_run(mock_sync, mock_ever, mock_azure):
    """
    Should call Synchronizer with proper arguments
    """
    conf = SyncRunner.load_config('./config/sampleConfig.json')
    # Create mocks
    azure = MagicMock()
    azure.setup = MagicMock()
    mock_azure.Azure.return_value = azure
    everbridge = MagicMock()
    mock_ever.Everbridge.return_value = everbridge
    sync = MagicMock()
    sync.run_with_map = MagicMock()
    mock_sync.Synchronizer.return_value = sync
    # Call SyncRuunner#run
    runner = SyncRunner('./config/sampleConfig.json')
    runner.run()
    # Test if each function is called properly
    mock_azure.Azure.assert_called_with(conf['clientId'],
                                  conf['clientSecret'],
                                  conf['adTenant'])
    mock_ever.Everbridge.assert_called_with(conf['everbridgeOrg'],
                                 conf['everbridgeUsername'],
                                 conf['everbridgePassword'])
    mock_sync.Synchronizer.assert_called_with(azure, everbridge)
    sync.run_with_map.assert_called_with(conf['adGroupId'], conf["adMemberId"], conf["parentGroup"])
Ejemplo n.º 2
0
def test_load_config():
    """
    Should return config object
    """
    conf = SyncRunner.load_config('./config/sampleConfig.json')
    exp = {
        'clientId':'Azure AD Client ID',
        'clientSecret':'Azure AD Client Secret',
        'everbridgeUsername':'******',
        'everbridgePassword':'******',
        'everbridgeOrg':'EverBridge Org',
        'adTenant':'Azure AD Tenant',
        'parentGroup': 'Parent Group',
        'adMemberId':['Azure AD Member ID1', 'Azure AD Member ID2'],
        'adGroupId':['Azure AD Group ID1', 'Azure AD Group ID2'],
        'logFileName':'test.log',
        'logLevel':'DEBUG'
    }
    assert conf == exp
Ejemplo n.º 3
0
def test_load_config_with_nonexistent_file():
    """
    Should return config object
    """
    with pytest.raises(SyncRunnerException):
        SyncRunner.load_config('NOTEXIST.json')