protected virtual Action <OnCreatingContext <TObjectType, TDefinitionType> > CreateOnProvisionedHook <TObjectType, TDefinitionType>() where TDefinitionType : DefinitionBase { return(new Action <OnCreatingContext <TObjectType, TDefinitionType> >(context => { var id = context.GetType().GetGenericArguments()[0].AssemblyQualifiedName + ":" + context.ObjectDefinition.GetHashCode(); var hook = _hookMap[id]; hook.OnProvisioned = true; var farmDef = context.ObjectDefinition as FarmSolutionDefinition; if (farmDef != null && farmDef.ShouldDelete == true) { // by passing checking the object within onb provisioed event // farm solution is expected to be deleted } else { if (context.Object == null) { Console.WriteLine(""); } AssertService.IsNotNull(context.Object); AssertService.IsNotNull(context.ObjectDefinition); AssertService.IsNotNull(context.ModelHost); AssertService.IsInstanceOfType(context.Object, typeof(TObjectType)); } })); }
protected void ResolveHook(EventHooks eventHooks, string start) { TraceUtils.WithScope(traceScope => { if (eventHooks.OnProvisioning) { if (!ShowOnlyFalseResults) { traceScope.WriteLine(string.Format("[INF]{0} [VALIDATED] - [OnProvisioning]", start)); } } else { traceScope.WriteLine(string.Format("[ERR]{0} [MISSED] - [OnProvisioning]", start)); } if (eventHooks.OnProvisioned) { if (!ShowOnlyFalseResults) { traceScope.WriteLine(string.Format("[INF]{0} [VALIDATED] - [OnProvisioned]", start)); } } else { traceScope.WriteLine(string.Format("[IERR]{0} [MISSED] - [OnProvisioned]", start)); } AssertService.AreEqual(true, eventHooks.OnProvisioning); AssertService.AreEqual(true, eventHooks.OnProvisioned); }); }
public void TestModels(IEnumerable <ModelNode> models) { // force XML serialiation EnsureSerializationSupport(models); _hookMap.Clear(); foreach (var model in models) { var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; var omModelType = GetRunnerType(runner); var hooks = GetHooks(model); foreach (var hook in hooks) { hook.Tag = runner.Name; } allHooks.AddRange(hooks); if (model.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(model); } else if (model.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(model); } else if (model.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(model); } else if (model.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(model); } else if (model.Value.GetType() == typeof(ListDefinition)) { runner.DeployListModel(model); } else { throw new SPMeta2NotImplementedException( string.Format("Runner does not support model of type: [{0}]", model.Value.GetType())); } if (this.EnableDefinitionValidation) { var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); } }); } }
public void TestToDeleteProject() { RestRequest GetRequest = RequestFactory.ProjectRequest(_requestUrlUpdateProject, Method.DELETE, NewProject); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AreEqual(StatusCode.Accepted.ToString(), statusCode); }
public void TestGetUserState() { RestRequest GetRequest = RequestFactory.UserRequest(_requestUrlGetUserState, Method.GET, _userId); IRestResponse RestResponse = Client.Execute(GetRequest); string state = JsonDeserializer.ReturnJsonValue("state", RestResponse);; AssertService.AreEqual(state, _state); }
public void TestUnarchiveProject() { RestRequest GetRequest = RequestFactory.ProjectRequest(_requestUrlUnarchived, Method.POST, _projectId); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AreEqual(StatusCode.Created.ToString(), statusCode); }
public void TestDeleteBranch() { RestRequest GetRequest = RequestFactory.BranchRequest(_requestUrlDeleteBranch, Method.DELETE, _projectId, _newBranch); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AreEqual(StatusCode.NoContent.ToString(), statusCode.ToString()); }
public void TestGetNameSpaces() { RestRequest GetRequest = RequestFactory.CustomRequest(_requestUrlNamespaces, Method.GET); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AreEqual(StatusCode.Ok.ToString().ToUpper(), statusCode); }
public void TestDeleteWikiPage() { RestRequest GetRequest = RequestFactory.ProjectRequest(_requestUrlWikiDelete, Method.DELETE, NewProject); GetRequest.AddUrlSegment("slug", _wikiTitle); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AreEqual(StatusCode.NoContent.ToString(), statusCode); }
public void TestCreateWikiPage() { object json = WikiJsonBody.SetContent(_wikiContent).SetTitle(_wikiTitle).Build(); RestRequest GetRequest = RequestFactory.ProjectRequestWithJson(_requestUrlWiki, Method.POST, NewProject, json); IRestResponse RestResponse = Client.Execute(GetRequest); string title = JsonDeserializer.ReturnJsonValue("title", RestResponse);; AssertService.AreEqual(_wikiTitle, title); }
public void TestAddEmailThatAlreadyExisted() { object json = UserJsonBodyBuilder.SetId(_userId).SetEmail(_email).Build(); RestRequest GetRequest = RequestFactory.RequestWithJsonBody(_requestUrlEmails, Method.POST, json); IRestResponse RestResponse = Client.Execute(GetRequest); string message = RegexMessage.RegexWarningMessage(JsonDeserializer.ReturnJsonValue("message", RestResponse)); AssertService.AreEqual(_warningMessageExistedEmail, message); }
public void TestUpdateUserStatusMessage() { object json = UserJsonBodyBuilder.SetMessage(_message).Build(); RestRequest GetRequest = RequestFactory.RequestWithJsonBody(_requestUrlUserStatus, Method.PUT, json); IRestResponse RestResponse = Client.Execute(GetRequest); string message = JsonDeserializer.ReturnJsonValue("message", RestResponse);; AssertService.AreEqual(_message, message); }
public void TestRenameProject() { object json = ProjectJsonBody.SetDescription(_description).SetName(_newProjectName).Build(); RestRequest GetRequest = RequestFactory.ProjectRequestWithJson(_requestUrlUpdateProject, Method.PUT, NewProject, json); IRestResponse RestResponse = Client.Execute(GetRequest); string name = JsonDeserializer.ReturnJsonValue("name", RestResponse);; AssertService.AreEqual(_newProjectName, name); }
public void TestArchiveProject() { RestRequest GetRequest = RequestFactory.ProjectRequest(_requestUrlArchived, Method.POST, _projectId); IRestResponse RestResponse = Client.Execute(GetRequest); _logger.Info($"Response {RestResponse.ResponseUri} received"); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AssertEqual(StatusCode.Created.ToString(), statusCode); }
public void TestAddFileWithAlreadyExistedName() { object json = new FileJsonBodyChield(_fileName, _branch, _content, _commitMessage); RestRequest GetRequest = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json); IRestResponse RestResponse = Client.Execute(GetRequest); string message = JsonDeserializer.ReturnJsonValue("message", RestResponse);; AssertService.AssertEqual(_errorMessageUploadFileWithExistedName, message); }
private void UploadFileToRepo(string fileName, string branch, string content, string commit, Method method, string expectedStatusCode) { object json = new FileJsonBodyChield(fileName, branch, content, commit); RestRequest GetRequest = RequestFactory.FileRequest(_requestUrlFile, method, _projectId, fileName, json); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AssertEqual(statusCode, statusCode); }
public void TestUploadFileWithoutSelectBrunch() { object json = new FileJsonBodyChield(_fileName, _commitMessage); RestRequest GetRequest = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json); IRestResponse RestResponse = Client.Execute(GetRequest); string message = JsonDeserializer.ReturnJsonValue("message", RestResponse);; AssertService.AreEqual(_errorMessageUploadFileIncorrectBrunch, message); }
public void TestUploadFileWithoutCommitMessage() { object json = new FileJsonBody(_fileName, _branch); RestRequest GetRequest = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json); IRestResponse RestResponse = Client.Execute(GetRequest); string error = JsonDeserializer.ReturnJsonValue("error", RestResponse);; AssertService.AssertEqual(_errorMessageUploadFileWithoutCommitMessage, error); }
public void TestToUploadFileToArchivedRepository() { object json = new FileJsonBodyChield(_fileName, _branch, _commitMessage, _commitMessage); RestRequest GetRequest = RequestFactory.FileRequest(_requestUrlFile, Method.POST, _projectId, _fileName, json); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AreEqual(StatusCode.Forbidden.ToString(), statusCode); }
public void TestCreateNewBrunch() { RestRequest GetRequest = RequestFactory.BranchRequest(_requestUrlBranch, Method.POST, _projectId, _newBranch); GetRequest.AddUrlSegment("branch", _branch); IRestResponse RestResponse = Client.Execute(GetRequest); string statusCode = RestResponse.StatusCode.ToString(); AssertService.AreEqual(StatusCode.Created.ToString(), statusCode); }
public void TestUpdateUserStatusMessage() { object json = UserJsonBodyBuilder.SetMessage(_message).Build(); RestRequest GetRequest = RequestFactory.ProjectRequest(_requestUrlUserStatus, Method.PUT, json); IRestResponse RestResponse = Client.Execute(GetRequest); _logger.Info($"Response {RestResponse.ResponseUri} received"); string message = JsonDeserializer.ReturnJsonValue("message", RestResponse);; AssertService.AssertEqual(_message, message); }
protected virtual Action <OnCreatingContext <TObjectType, TDefinitionType> > CreateOnProvisioningHook <TObjectType, TDefinitionType>() where TDefinitionType : DefinitionBase { return(new Action <OnCreatingContext <TObjectType, TDefinitionType> >(context => { var id = context.GetType().GetGenericArguments()[0].AssemblyQualifiedName + ":" + context.ObjectDefinition.GetHashCode(); var hook = _hookMap[id]; hook.OnProvisioning = true; AssertService.IsNotNull(context.ObjectDefinition); })); }
public void TestAddProject() { object json = ProjectJsonBody.SetDescription(_description).SetName(_projectName).Build(); RestRequest GetRequest = RequestFactory.RequestWithJsonBody("projects", Method.POST, json); IRestResponse RestResponse = Client.Execute(GetRequest); //Set project id NewProject = int.Parse(JsonDeserializer.ReturnJsonValue("id", RestResponse)); string name = JsonDeserializer.ReturnJsonValue("name", RestResponse);; AssertService.AreEqual(_projectName, name); }
public void TestModels(IEnumerable <ModelNode> models) { _hookMap.Clear(); foreach (var model in models) { var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; //ValidateDefinitionHostRunnerSupport<TDefinition>(runner); var omModelType = GetRunnerType(runner); var hooks = GetHooks(model); foreach (var hook in hooks) { hook.Tag = runner.Name; } allHooks.AddRange(hooks); if (model.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(model); } if (model.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(model); } if (model.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(model); } if (model.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(model); } var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); }); } }
public static void PerformAction(string keyword, RestClient client, string value, StatusCode statusCode, string branchName) { switch (keyword) { case ("request"): GetRequestFactory(value, branchName); break; case ("addSegment"): _logger.Info($"Adding header \"branch\": {value}"); _restRequest.AddUrlSegment("branch", value); break; case "response": IRestResponse response = client.Execute(_restRequest); _logger.Info($"Response {response.ResponseUri} received"); _statusCode = response.StatusCode.ToString(); break; case "assert": AssertService.AssertEqual(statusCode.ToString(), _statusCode); break; } }
public ModelNode TestRandomDefinition <TDefinition>(Action <TDefinition> definitionSetup) where TDefinition : DefinitionBase, new() { _hookMap.Clear(); ModelNode result = null; var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; ValidateDefinitionHostRunnerSupport <TDefinition>(runner); var omModelType = GetRunnerType(runner); var definitionSandbox = ModelGeneratorService.GenerateModelTreeForDefinition <TDefinition>(omModelType); var additionalDefinitions = ModelGeneratorService.GetAdditionalDefinition <TDefinition>(); ModelGeneratorService.ComposeModelWithAdditionalDefinitions(definitionSandbox, additionalDefinitions, omModelType); if (definitionSetup != null) { foreach (var def in ModelGeneratorService.CurrentDefinitions) { definitionSetup(def as TDefinition); } } var hooks = GetHooks(definitionSandbox); foreach (var hook in hooks) { hook.Tag = runner.Name; } GetSerializedAndRestoredModels(definitionSandbox); allHooks.AddRange(hooks); if (definitionSandbox.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(definitionSandbox); } if (definitionSandbox.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(definitionSandbox); } if (definitionSandbox.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(definitionSandbox); } if (definitionSandbox.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(definitionSandbox); } if (this.EnableDefinitionValidation) { var hasMissedOrInvalidProps = ResolveModelValidation(definitionSandbox, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); } result = definitionSandbox; }); return(result); }
public void TestModels(IEnumerable <ModelNode> models, bool deployOnce) { // force XML serialiation GetSerializedAndRestoredModels(models); _hookMap.Clear(); foreach (var model in models) { Trace.WriteLine(string.Format(".ToPrettyPrint() result:")); Trace.WriteLine(model.ToPrettyPrint()); Trace.WriteLine(string.Format(".ToDotGraph result:")); Trace.WriteLine(model.ToDotGraph()); if (EnableDefinitionImmutabilityValidation) { PersistDefinitionHashes(new[] { model }); } var allHooks = new List <EventHooks>(); WithProvisionRunnerContext(runnerContext => { var runner = runnerContext.Runner; var omModelType = GetRunnerType(runner); var hooks = GetHooks(model); foreach (var hook in hooks) { hook.Tag = runner.Name; } allHooks.AddRange(hooks); if (model.Value.GetType() == typeof(FarmDefinition)) { runner.DeployFarmModel(model); } else if (model.Value.GetType() == typeof(WebApplicationDefinition)) { runner.DeployWebApplicationModel(model); } else if (model.Value.GetType() == typeof(SiteDefinition)) { runner.DeploySiteModel(model); } else if (model.Value.GetType() == typeof(WebDefinition)) { runner.DeployWebModel(model); } else if (model.Value.GetType() == typeof(ListDefinition)) { runner.DeployListModel(model); } else { throw new SPMeta2NotImplementedException( string.Format("Runner does not support model of type: [{0}]", model.Value.GetType())); } if (!deployOnce) { if (this.EnableDefinitionValidation) { var hasMissedOrInvalidProps = ResolveModelValidation(model, hooks); AssertService.IsFalse(hasMissedOrInvalidProps); } } }); if (!deployOnce) { if (EnableDefinitionImmutabilityValidation) { PleaseMakeSureDefinitionsWereNotChangedByModelHandlers(new[] { model }); } } } }
public void CorrectLoginTest() { LoginService.LogIn(_correctLoginName, _correctLoginPass); AssertService.AssetEqual(LoginService.GetLoginName(), StringTransform.FirstUpper(_correctLoginName)); }
public void AnErrorMsgIfIncorrectPassLoginTest() { LoginService.LogIn(_incorrectLoginName, _incorrectLoginPath); AssertService.AssetEqual(LoginService.GetErrorMessage(), _loginPopUperrorMsg); }