public void GivenIHaveAServer(string serverName) { if(serverName != "localhost") { var environmentModel = new EnvironmentModel(Guid.NewGuid(), new ServerProxy(new Uri(string.Format("http://{0}:3142", serverName)))); EnvironmentRepository.Instance.Save(environmentModel); environmentModel.Connect(); } }
static void TestAuxilliaryConnections(string appServerUri) { var repo = new Mock<IResourceRepository>(); var sRepo = new Mock<IStudioResourceRepository>(); var connection = CreateConnection(appServerUri); var environment = new EnvironmentModel(Guid.NewGuid(), connection, repo.Object,sRepo.Object) { Name = "conn" }; var auxRepo = new Mock<IResourceRepository>(); var auxConnection = CreateConnection(appServerUri); var auxEnvironment = new EnvironmentModel(Guid.NewGuid(), auxConnection, auxRepo.Object,sRepo.Object) { Name = "auxconn" }; environment.Connect(); Assert.IsTrue(environment.IsConnected); auxEnvironment.Connect(environment); Assert.IsTrue(auxEnvironment.IsConnected); auxEnvironment.Disconnect(); environment.Disconnect(); }
public void WhenConnectedAsUserPartOf(string userGroup) { if(SchedulerSteps.AccountExists("SpecsUser")) { if(!IsUserInGroup("SpecsUser", userGroup)) { try { SecurityIdentifier id = SchedulerSteps.GetUserSecurityIdentifier("SpecsUser"); PrincipalContext context = new PrincipalContext(ContextType.Machine); UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context, IdentityType.Sid, id.Value); SchedulerSteps.AddUserToGroup(userGroup, context, userPrincipal); } catch(Exception) { Assert.Fail("User not found"); } } } else { SchedulerSteps.CreateLocalWindowsAccount("SpecsUser", "T35t3r!@#", userGroup); } var reconnectModel = new EnvironmentModel(Guid.NewGuid(), new ServerProxy(AppSettings.LocalHost, "SpecsUser", "T35t3r!@#")) { Name = "Other Connection" }; try { reconnectModel.Connect(); } catch(UnauthorizedAccessException) { Assert.Fail("Connection unauthorized when connecting to local Warewolf server as user who is part of '" + userGroup + "' user group."); } ScenarioContext.Current.Add("currentEnvironment", reconnectModel); }