public void SetupFromConfiguration() { foreach (var app in application_profiles) { _dscLogic.MakeItSoPolicy(app, app.policy); _dscLogic.MakeItSoApp(app); _dscLogic.MakeItSoTeam(app); _dscLogic.MakeItSoSandboxes(app); foreach (var user in app.users) { user.teams = app.application_name; user.email_address = _rand.Next(1000000).ToString() + user.email_address; _dscLogic.MakeItSoUser(user, app); } Assert.IsTrue(_veracodeService.DoesAppExist(app)); Assert.IsTrue(_veracodeService.DoesPolicyExist(app)); Assert.IsTrue(_veracodeService.DoesTeamExistForApp(app)); Assert.IsTrue(_veracodeService.DoSandboxesExistForApp(app)); foreach (var user in app.users) { Assert.IsTrue(_veracodeService.DoesUserExist(user)); } } }
public void MakeItSoTeam(ApplicationProfile app) { _logger.LogInformation($"Checking to see if team {app.application_name} already exists."); if (!_veracodeService.DoesTeamExistForApp(app)) { _logger.LogInformation($"Team {app.application_name} does not exist, adding configuration."); try { _veracodeService.CreateTeamForApp(app); _logger.LogInformation($"Team {app.application_name} created succesfully."); } catch (Exception e) { _logger.LogError($"Team {app.application_name} could not be created!"); _logger.LogError($"{e.Message}."); } return; } _logger.LogInformation($"Team {app.application_name} exists."); var usersInTeam = _veracodeService.GetUserEmailsOnTeam(app); foreach (var user in usersInTeam) { _logger.LogInformation($"Checking if {user.email_address} is assigned to team {app.application_name}."); if (!_veracodeService.IsUserAssignedToTeam(user, app)) { _logger.LogInformation($"User {user.email_address} is not assigned to team {app.application_name}, updating configuration."); try { if (string.IsNullOrEmpty(user.teams)) { user.teams = $"{app.application_name}"; } else { user.teams = $",{app.application_name}"; } _veracodeService.UpdateUser(user); _logger.LogInformation($"User {user.email_address} assigned to team {app.application_name} succesfully."); } catch (Exception e) { _logger.LogError($"User {user.email_address} could not be added to team {app.application_name}!"); _logger.LogError($"{e.Message}."); } } else { _logger.LogInformation($"User {user.email_address} is already assigned to team {app.application_name}."); } } }