Skip to content
Snippets Groups Projects
Commit eeacc200 authored by Klaus Fischer's avatar Klaus Fischer
Browse files

Implemented 3.11, 4.5

parent 94a7b714
No related branches found
No related tags found
1 merge request!24AutoReject planning#594
......@@ -23,6 +23,9 @@ public class Problems {
public const string TitleMissingSchema = "Schema-Referenz fehlt";
public const string DetailMissingSchema = "Die Schema-Referenz fehlt im Metadatensatz.";
public const string TitleSchemaViolationData = "Schema-Fehler";
public const string DetailsSchemaViolationData = "Der Fachdatensatz ist nicht schema-valide.";
public const string TitleUnsupportedService = "Verwaltungsleistung nicht unterstützt";
public const string DetailUnsupportedService = "Die angegebene Verwaltungsleistung wird nicht unterstützt.";
......@@ -64,6 +67,7 @@ public class Problems {
public enum ProblemInstanceEnum {
Submission,
Metadata,
Data
}
internal Problems() {
......@@ -124,8 +128,8 @@ public class Problems {
break;
case ProblemTypeEnum.SchemaViolation:
type += "schema-violation";
title = TitleEventLogInconsistent;
instance = "submission";
title = TitleSchemaViolationData;
instance = "data";
break;
case ProblemTypeEnum.SyntaxViolation:
type += "syntax-violation";
......
......@@ -188,8 +188,14 @@ public class Subscriber : FitConnectClient,
if (destinationService.SubmissionSchemas != null && destinationService.SubmissionSchemas
.Select(s => s.SchemaUri)
.Contains(dataSchema)) {
CheckDataSchema(dataSchema, submission);
var problem = new Problems(Problems.ProblemTypeEnum.UnsupportedDataSchema,
Problems.DetailUnsupportedDataSchema);
RejectSubmission(submission, problem);
throw new SecurityEventException(problem);
}
// SuccessCriteria:4.5
CheckDataSchema(dataSchema, submission);
}
......@@ -216,8 +222,8 @@ public class Subscriber : FitConnectClient,
var isValidSchemaData = JObject.Parse(submission.Data!).IsValid(jSchema);
if (!isValidSchemaData) {
var problem = new Problems(Problems.ProblemTypeEnum.UnsupportedDataSchema,
Problems.DetailUnsupportedDataSchema);
var problem = new Problems(Problems.ProblemTypeEnum.SchemaViolation,
Problems.DetailsSchemaViolationData);
RejectSubmission(submission, problem);
throw new SecurityEventException(problem);
}
......
......@@ -90,6 +90,16 @@ public class SenderTestHappyPath : SenderTestBase {
submission.Should().NotBeNull();
}
private class SampleData {
[JsonProperty(PropertyName = "$schema", Order = -2)]
public string Schema { get; set; } =
"https://git.fitko.de/fit-connect/sdk-dotnet/-/raw/feature/594-auto-reject/simple_schema.json";
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
[Test]
public void Submit_FinishSubmissionWithData_ShouldGetIdFromServer() {
// Arrange
......@@ -108,11 +118,11 @@ public class SenderTestHappyPath : SenderTestBase {
.WithDestination(DestinationId)
.WithServiceType("ServiceName", "urn:de:fim:leika:leistung:99400048079000")
.WithAttachments(attachments)
.WithJsonData(JsonConvert.SerializeObject(new {
.WithJsonData(JsonConvert.SerializeObject(new SampleData{
FirstName = "John",
LastName = "Doe",
Age = 42,
Birthday = DateTime.Today.AddYears(-42)
// Birthday = DateTime.Today.AddYears(-42)
}));
// Act
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment