public async Task WebApi_GetUserInfoUsingEntitiesEndpoint_ReturnsError() { var response = await UnauthorizedApi.GetUserEntityById(JohnId); response.IsSuccessStatusCode.Should().Be(false); response.StatusCode.Should().Be(HttpStatusCode.Forbidden); }
public async Task WebApi_GetUserInfoUsingNodesEndpoint_ReturnsError() { var response = await UnauthorizedApi.GetNodeById(JohnId); response.IsSuccessStatusCode.ShouldBeEquivalentTo(false); response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.Forbidden); }
public async Task Stream_GetStreamUnauthorizedUser_ExpectedOneStream() { var response = await UnauthorizedApi.GetStreamFileEntityById(FileId, 0, 1); var streams = JArray.Parse(await response.Content.ReadAsStringAsync()); streams.Should().NotBeEmpty(); streams.Should().HaveCount(1); var stream = streams.First(); stream.Should().ContainsJson($@" {{ 'name': 'FileCreated', 'namespace': 'Sds.Osdr.Generic.Domain.Events.Files', 'event': {{ 'bucket': '{JohnId.ToString()}', 'blobId': '{BlobId}', 'parentId': '{JohnId}', 'fileName': 'Aspirin.mol', 'fileStatus': 'Loaded', 'fileType': 'Records', 'id': '{FileId}', 'userId': '{JohnId}', 'version': 1 }} }}" ); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedNotFoundRecordEntity() { var response = await UnauthorizedApi.GetNodesById(FileId); response.IsSuccessStatusCode.Should().Be(false); // response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NotFound); // response.ReasonPhrase.ShouldAllBeEquivalentTo("Not Found"); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsRecordNotFound() { var response = await UnauthorizedApi.GetRecordEntityById(FileId); response.IsSuccessStatusCode.Should().Be(false); response.StatusCode.Should().Be(HttpStatusCode.NotFound); response.ReasonPhrase.Should().Be("Not Found"); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedNotFoundFileNode() { var response = await UnauthorizedApi.GetNodeById(FileId); var sharedInfo = JsonConvert.DeserializeObject <JObject>(await response.Content.ReadAsStringAsync()); response.IsSuccessStatusCode.Should().Be(false); // response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NotFound); // response.ReasonPhrase.ShouldAllBeEquivalentTo("Not Found"); }
public async Task FileSharing_UnauthorizedRequestForEntitiesFiles_ReturnsExpectedResults() { var response = await UnauthorizedApi.GetPublicEntity("Files"); response.EnsureSuccessStatusCode(); var nodes = JToken.Parse(await response.Content.ReadAsStringAsync()); nodes.ContainsNodes(_testFixture.InternalIds).ShouldBeEquivalentTo(2); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedBlobFile() { var blobResponse = await UnauthorizedApi.GetBlobFileEntityById(FileId, BlobId); blobResponse.EnsureSuccessStatusCode(); blobResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK); blobResponse.Content.Headers.ContentType.MediaType.ShouldBeEquivalentTo("application/octet-stream"); blobResponse.Content.Headers.ContentLength.ShouldBeEquivalentTo(1689); //blobResponse.Content.Headers.ContentDisposition.FileName.ShouldBeEquivalentTo("Aspirin.mol"); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedNotFound() { var blobInfo = await BlobStorage.GetFileInfo(BlobId, JohnId.ToString()); blobInfo.Should().NotBeNull(); var response = await UnauthorizedApi.GetNodeEntityById(FileId); response.IsSuccessStatusCode.ShouldBeEquivalentTo(false); response.StatusCode.ShouldBeEquivalentTo(400); response.ReasonPhrase.ShouldAllBeEquivalentTo("Bad Request"); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedRecordEntity() { var recordResponse = await UnauthorizedApi.GetNodesById(FileId); var recordNodes = JsonConvert.DeserializeObject <JArray>(await recordResponse.Content.ReadAsStringAsync()); var recordId = recordNodes.First()["id"].ToObject <Guid>(); recordId.Should().NotBeEmpty(); var recordEntityResponse = await JohnApi.GetRecordEntityById(recordId); var recordEntity = JsonConvert.DeserializeObject <JObject>(await recordEntityResponse.Content.ReadAsStringAsync()); recordEntity.Should().NotBeEmpty(); recordEntity.Should().ContainsJson($@" {{ 'id': '{recordId}', 'type': 'Structure', 'fileId': '{FileId}', 'blob': {{ 'bucket': '{JohnId}', }}, 'ownedBy': '{JohnId}', 'createdBy': '{JohnId}', 'createdDateTime': '{DateTime.UtcNow}', 'updatedBy': '{JohnId}', 'updatedDateTime': '{DateTime.UtcNow}', 'index': 0, 'status': '{FileStatus.Processed}', 'version': *EXIST*, 'properties': {{ 'fields': [ {{ 'name': 'StdInChI', 'value': 'InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)' }}, {{ 'name': 'StdInChIKey', 'value': 'BSYNRYMUTXBXSQ-UHFFFAOYSA-N' }}, {{ 'name': 'SMILES', 'value': 'CC(OC1=C(C(=O)O)C=CC=C1)=O' }} ], 'chemicalProperties': *EXIST* }} }}" ); recordEntity["images"].Should().NotBeNull(); recordEntity["images"].Should().HaveCount(1); }
public async Task BlobImageSharing_WithUnauthorizeUser_ReturnsExpectedNotFound() { var fileResponse = await JohnApi.GetFileEntityById(FileId); var file = JObject.Parse(await fileResponse.Content.ReadAsStringAsync()); var imageId = file["images"].First()["id"].ToObject <Guid>(); var response = await UnauthorizedApi.GetImagesFileEntityById(FileId, imageId); response.IsSuccessStatusCode.Should().Be(false); // response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NotFound); // response.ReasonPhrase.ShouldAllBeEquivalentTo("Not Found"); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedImage() { var fileResponse = await JohnApi.GetFileEntityById(FileId); var file = JObject.Parse(await fileResponse.Content.ReadAsStringAsync()); var imageId = file["images"].First()["id"].ToObject <Guid>(); var blobResponse = await UnauthorizedApi.GetImagesFileEntityById(FileId, imageId); blobResponse.EnsureSuccessStatusCode(); blobResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK); blobResponse.Content.Headers.ContentType.MediaType.ShouldBeEquivalentTo("application/octet-stream"); blobResponse.Content.Headers.ContentLength.Should().BeGreaterThan(10000); blobResponse.Content.Headers.ContentDisposition.FileName.ShouldBeEquivalentTo("Aspirin.mol.svg"); }
public async Task WebApi_GetUserPublicInfo_ReturnsError() { var response = await UnauthorizedApi.GetUserPublicInfoById(JohnId); response.EnsureSuccessStatusCode(); var user = JObject.Parse(await response.Content.ReadAsStringAsync()); user.Should().ContainsJson($@" {{ 'id': '{JohnDoe.Id}', 'displayName': '{JohnDoe.DisplayName}', 'firstName': '{JohnDoe.FirstName}', 'lastName': '{JohnDoe.LastName}', 'avatar': '{JohnDoe.Avatar}' }}" ); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedNotFoundRecordNode() { var recordResponse = await JohnApi.GetNodesById(FileId); var recordNodes = JsonConvert.DeserializeObject <JArray>(await recordResponse.Content.ReadAsStringAsync()); var recordId = recordNodes.First()["id"].ToObject <Guid>(); recordId.Should().NotBeEmpty(); var response = await UnauthorizedApi.GetNodeById(recordId); response.IsSuccessStatusCode.Should().Be(false); // response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NotFound); // response.ReasonPhrase.ShouldAllBeEquivalentTo("Not Found"); }
public async Task BlobImageRecordSharing_WithUnauthorizeUser_ReturnsExpectedNotFound() { var nodeRecordResponse = await JohnApi.GetNodesById(FileId); var nodeRecord = JArray.Parse(await nodeRecordResponse.Content.ReadAsStringAsync()).First(); var nodeRecordId = nodeRecord["id"].ToObject <Guid>(); var recordResponse = await JohnApi.GetRecordEntityById(nodeRecordId); var record = JObject.Parse(await recordResponse.Content.ReadAsStringAsync()); var recordId = record["id"].ToObject <Guid>(); var imageId = record["images"].First()["id"].ToObject <Guid>(); var response = await UnauthorizedApi.GetImagesRecordEntityById(recordId, imageId); response.IsSuccessStatusCode.ShouldBeEquivalentTo(false); // response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NotFound); // response.ReasonPhrase.ShouldAllBeEquivalentTo("Not Found"); }
public async Task FileSharing_WithUnAuthorizeUser_ReturnsExpectedPublicNodesFilter() { var response = await UnauthorizedApi.GetNodes("Type eq 'File'"); // TODO: Refactoring var nodes = JToken.Parse(await response.Content.ReadAsStringAsync()); nodes.Should().HaveCount(1); var fileNames = new[] { "ringcount_0.mol" }; foreach (var node in nodes) { if (node["type"].ToObject <string>() == "File") { fileNames.Contains(node["name"].ToObject <string>()).Should().BeTrue(); } } }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedBlobRecord() { var nodeRecordResponse = await JohnApi.GetNodesById(FileId); var nodeRecord = JArray.Parse(await nodeRecordResponse.Content.ReadAsStringAsync()).First(); var nodeRecordId = nodeRecord["id"].ToObject <Guid>(); var recordResponse = await JohnApi.GetRecordEntityById(nodeRecordId); var record = JObject.Parse(await recordResponse.Content.ReadAsStringAsync()); var recordId = record["id"].ToObject <Guid>(); var recordBlobId = record["blob"]["id"].ToObject <Guid>(); var blobResponse = await UnauthorizedApi.GetBlobRecordEntityById(recordId, recordBlobId); blobResponse.EnsureSuccessStatusCode(); blobResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK); blobResponse.Content.Headers.ContentType.MediaType.ShouldBeEquivalentTo("chemical/x-mdl-molfile"); blobResponse.Content.Headers.ContentLength.ShouldBeEquivalentTo(1689); //blobResponse.Content.Headers.ContentDisposition.FileName.Should().NotBeNullOrEmpty(); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedImageRecord() { var nodeRecordResponse = await JohnApi.GetNodesById(FileId); var nodeRecord = JArray.Parse(await nodeRecordResponse.Content.ReadAsStringAsync()).First(); var nodeRecordId = nodeRecord["id"].ToObject <Guid>(); var recordResponse = await JohnApi.GetRecordEntityById(nodeRecordId); var record = JObject.Parse(await recordResponse.Content.ReadAsStringAsync()); var recordId = record["id"].ToObject <Guid>(); var imageId = record["images"].First()["id"].ToObject <Guid>(); var blobResponse = await UnauthorizedApi.GetImagesRecordEntityById(recordId, imageId); blobResponse.EnsureSuccessStatusCode(); blobResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK); blobResponse.Content.Headers.ContentType.MediaType.ShouldBeEquivalentTo("application/octet-stream"); blobResponse.Content.Headers.ContentLength.ShouldBeEquivalentTo(10998); blobResponse.Content.Headers.ContentDisposition.FileName.ShouldBeEquivalentTo("Aspirin.mol.svg"); }
public async Task FileSharing_WithAuthorizeUser_ReturnsExpectedBlobFileAndRecord() { var nodeRecordResponse = await JohnApi.GetNodesById(FileId); var nodeRecord = JArray.Parse(await nodeRecordResponse.Content.ReadAsStringAsync()).First(); var nodeRecordId = nodeRecord["id"].ToObject <Guid>(); var recordResponse = await JohnApi.GetRecordEntityById(nodeRecordId); var record = JObject.Parse(await recordResponse.Content.ReadAsStringAsync()); var recordId = record["id"].ToObject <Guid>(); var recordBlobId = record["blob"]["id"].ToObject <Guid>(); var blobRecordResponse = await JohnApi.GetBlobRecordEntityById(recordId, recordBlobId); var recordString = await blobRecordResponse.Content.ReadAsStringAsync(); var blobFileResponse = await UnauthorizedApi.GetBlobFileEntityById(FileId, BlobId); var fileString = await blobFileResponse.Content.ReadAsStringAsync(); recordString.Should().BeEquivalentTo(fileString); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedFileEntity() { var blobInfo = await BlobStorage.GetFileInfo(BlobId, JohnId.ToString()); blobInfo.Should().NotBeNull(); var fileEntityResponse = await UnauthorizedApi.GetFileEntityById(FileId); fileEntityResponse.EnsureSuccessStatusCode(); fileEntityResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK); var fileEntity = JsonConvert.DeserializeObject <JObject>(await fileEntityResponse.Content.ReadAsStringAsync()); fileEntity.Should().ContainsJson($@" {{ 'id': '{FileId}', 'blob': {{ 'id': '{blobInfo.Id}', 'bucket': '{JohnId}', 'length': {blobInfo.Length}, 'md5': '{blobInfo.MD5}' }}, 'subType': '{FileType.Records}', 'ownedBy': '{JohnId}', 'createdBy': '{JohnId}', 'createdDateTime': '{DateTime.UtcNow}', 'updatedBy': '{JohnId}', 'updatedDateTime': '{DateTime.UtcNow}', 'parentId': '{JohnId}', 'name': '{blobInfo.FileName}', 'status': '{FileStatus.Processed}', 'version': *EXIST*, 'totalRecords': 1, }}" ); fileEntity["properties"].Should().NotBeEmpty(); fileEntity["properties"].Should().HaveCount(2); fileEntity["images"].Should().HaveCount(1); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedRecordNode() { var recordResponse = await UnauthorizedApi.GetNodesById(FileId); var recordNodes = JsonConvert.DeserializeObject <JArray>(await recordResponse.Content.ReadAsStringAsync()); var recordId = recordNodes.First()["id"].ToObject <Guid>(); recordId.Should().NotBeEmpty(); var recordNodeResponse = await JohnApi.GetNodeById(recordId); var recordNode = JsonConvert.DeserializeObject <JObject>(await recordNodeResponse.Content.ReadAsStringAsync()); recordNode.Should().NotBeEmpty(); recordNode.Should().ContainsJson($@" {{ 'id': '{recordId}', 'type': 'Record', 'subType': 'Structure', 'name': 0, 'blob': {{ 'bucket': '{JohnId}' }}, 'ownedBy':'{JohnId}', 'createdBy':'{JohnId}', 'createdDateTime': '{DateTime.UtcNow}', 'updatedBy':'{JohnId}', 'updatedDateTime': '{DateTime.UtcNow}', 'parentId': '{FileId}', 'version': *EXIST*, 'status': '{FileStatus.Processed}', }}" ); recordNode["images"].Should().NotBeNull(); recordNode["images"].Should().HaveCount(1); }
public async Task WebApi_NotAuthorizedAccessToProtectedResource_ReturnsUnauthorizedResponse() { var response = await UnauthorizedApi.GetNodesMe(); response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); }
public async Task UserOperation_GetNodesMeByUnauthorizedUser_ReturnsUnauthorizedAccess() { var response = await UnauthorizedApi.GetNodesMe(); response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); }
public async Task UserOperation_GetUserInfoByUnauthorizedUser_ReturnsUnauthorizedAccess() { var response = await UnauthorizedApi.GetUserById(JohnId); response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); }
public async Task WebApi_GetUserInfoUsingMeEndpoint_ReturnsError() { var response = await UnauthorizedApi.GetUserMe(); response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); }