public async Task EditMetadataBadRequest(string badName) { string url = ApiPaths.ALGO_STORE_METADATA; CreateAlgoDTO metadata = new CreateAlgoDTO() { Name = Helpers.RandomString(8), Description = Helpers.RandomString(8) }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK)); AlgoDataDTO responseMetaData = JsonUtils.DeserializeJson <AlgoDataDTO>(response.ResponseJson); url = ApiPaths.ALGO_STORE_METADATA; EditAlgoDTO editMetaData = new EditAlgoDTO() { Id = responseMetaData.Id, Name = badName, Description = badName }; var responseMetaDataAfterEdit = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); Assert.That(responseMetaDataAfterEdit.Status, Is.EqualTo(HttpStatusCode.BadRequest)); }
public async Task DeleteMetadataBadRequest(string badID) { string url = ApiPaths.ALGO_STORE_METADATA; CreateAlgoDTO metadata = new CreateAlgoDTO() { Name = Helpers.RandomString(8), Description = Helpers.RandomString(8) }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK)); AlgoDataDTO responseMetaData = JsonUtils.DeserializeJson <AlgoDataDTO>(response.ResponseJson); CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { AlgoId = badID, InstanceId = responseMetaData.Name }; url = ApiPaths.ALGO_STORE_CASCADE_DELETE; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.BadRequest)); }
public async Task CheckInvalidNamespaces(string invalidNamespace) { // Create timestamp that will be used in algo name var algoCreationTimestamp = Helpers.GetTimestampIso8601(); // Replace the default namespace with an invalid one var algoString = DummyAlgoString.Replace(GlobalConstants.AlgoDefaultNamespace, invalidNamespace); // Create algo object CreateAlgoDTO algoData = new CreateAlgoDTO() { Name = $"{algoCreationTimestamp}{GlobalConstants.AutoTest}_AlgoName", Description = $"{algoCreationTimestamp}{GlobalConstants.AutoTest}_AlgoName - Description", Content = Base64Helpers.EncodeToBase64(algoString) }; // Create algo var createAlgoResponse = await Consumer.ExecuteRequest(ApiPaths.ALGO_STORE_CREATE_ALGO, Helpers.EmptyDictionary, JsonUtils.SerializeObject(algoData), Method.POST); var message = $"POST {ApiPaths.ALGO_STORE_CREATE_ALGO} returned status: {createAlgoResponse.Status} and response: {createAlgoResponse.ResponseJson}. Expected: {HttpStatusCode.BadRequest}"; // Get user algos var userAlgos = (await GetUserAlgos()).Select(a => a.Name).ToList(); // Assert algo is not created Assert.Multiple(() => { Assert.That(createAlgoResponse.Status, Is.EqualTo(HttpStatusCode.BadRequest), message); Assert.That(createAlgoResponse.ResponseJson, Does.Contain("The provided namespace is not allowed").Or.Contains("Identifier expected")); Assert.That(userAlgos, Does.Not.Contain(algoData.Name)); }); }
public async Task UploadMetadataWithEmptyDescription() { string url = ApiPaths.ALGO_STORE_METADATA; CreateAlgoDTO metadata = new CreateAlgoDTO() { Name = Helpers.RandomString(8), Description = "" }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK)); AlgoDataDTO responseMetaData = JsonUtils.DeserializeJson <AlgoDataDTO>(response.ResponseJson); Assert.AreEqual(metadata.Name, responseMetaData.Name); Assert.AreEqual(metadata.Description, responseMetaData.Description); Assert.NotNull(responseMetaData.DateCreated); Assert.NotNull(responseMetaData.DateModified); Assert.NotNull(responseMetaData.Id); Assert.Null(responseMetaData.AlgoVisibility); MetaDataEntity metaDataEntity = await MetaDataRepository.TryGetAsync(t => t.Id == responseMetaData.Id) as MetaDataEntity; Assert.NotNull(metaDataEntity); Assert.AreEqual(metaDataEntity.Id, responseMetaData.Id); Assert.AreEqual(metaDataEntity.Name, responseMetaData.Name); Assert.AreEqual(metaDataEntity.Description, responseMetaData.Description); }
public async Task UpdateUploadedStringAlgo() { string url = ApiPaths.ALGO_STORE_METADATA; CreateAlgoDTO metadata = new CreateAlgoDTO() { Name = Helpers.RandomString(13), Description = Helpers.RandomString(13) }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); AlgoDataDTO responseMetaData = JsonUtils.DeserializeJson <AlgoDataDTO>(response.ResponseJson); url = ApiPaths.ALGO_STORE_UPLOAD_STRING; UploadStringDTO stringDTO = new UploadStringDTO() { AlgoId = responseMetaData.Id, Data = this.CSharpAlgoString }; var responsetemp = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(stringDTO), Method.POST); Assert.True(responsetemp.Status == System.Net.HttpStatusCode.NoContent); Dictionary <string, string> quaryParamGetString = new Dictionary <string, string>() { { "AlgoId", responseMetaData.Id } }; var responceGetUploadString = await this.Consumer.ExecuteRequest(url, quaryParamGetString, null, Method.GET); Assert.That(responceGetUploadString.Status, Is.EqualTo(HttpStatusCode.OK)); UploadStringDTO uploadedStringContent = JsonUtils.DeserializeJson <UploadStringDTO>(responceGetUploadString.ResponseJson); Assert.That(stringDTO.Data, Is.EqualTo(uploadedStringContent.Data)); UploadStringDTO UpdatedstringDTO = new UploadStringDTO() { AlgoId = responseMetaData.Id, Data = "Updated Text" }; var responsetempUpdated = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(UpdatedstringDTO), Method.POST); Assert.True(responsetempUpdated.Status == System.Net.HttpStatusCode.NoContent); var responceGetUploadStringUpdated = await this.Consumer.ExecuteRequest(url, quaryParamGetString, null, Method.GET); Assert.That(responceGetUploadStringUpdated.Status, Is.EqualTo(HttpStatusCode.OK)); UploadStringDTO uploadedStringContentUpdated = JsonUtils.DeserializeJson <UploadStringDTO>(responceGetUploadStringUpdated.ResponseJson); Assert.That(UpdatedstringDTO.Data, Is.EqualTo(uploadedStringContentUpdated.Data)); }
public async Task UploadMetadataBadRequest(string badName) { string url = ApiPaths.ALGO_STORE_METADATA; CreateAlgoDTO metadata = new CreateAlgoDTO() { Name = badName, Description = badName }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.BadRequest)); }
public async Task <AlgoDataDTO> CreateAlgo() { var algoCreationTimestamp = Helpers.GetFullUtcTimestamp(); CreateAlgoDTO metadata = new CreateAlgoDTO() { Name = $"{GlobalConstants.AutoTest}_AlgoMetaDataName_{algoCreationTimestamp}", Description = $"{ GlobalConstants.AutoTest }_AlgoMetaDataName_{algoCreationTimestamp} - Description", Content = Base64Helpers.EncodeToBase64(CSharpAlgoString) }; var createAlgoResponse = await Consumer.ExecuteRequest(ApiPaths.ALGO_STORE_CREATE_ALGO, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); message = $"POST {ApiPaths.ALGO_STORE_CREATE_ALGO} returned status: {createAlgoResponse.Status} and response: {createAlgoResponse.ResponseJson}. Expected: {HttpStatusCode.OK}"; Assert.That(createAlgoResponse.Status, Is.EqualTo(HttpStatusCode.OK), message); var algoData = JsonUtils.DeserializeJson <AlgoDataDTO>(createAlgoResponse.ResponseJson); // Add Algo to the list so that it can be deleted in the the TearDown algosList.Add(algoData); return(algoData); }