Skip to content

Commit 2072aea

Browse files
committed
wip
1 parent 6d09d01 commit 2072aea

File tree

4 files changed

+15
-370
lines changed

4 files changed

+15
-370
lines changed

rust/signed_doc/src/validator/rules/template.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ impl TemplateRule {
8484
return false;
8585
};
8686
match template_content_type {
87-
ContentType::Json | ContentType::SchemaJson => {
88-
templated_json_schema_check(doc, template_doc)
89-
},
90-
ContentType::Cddl
87+
ContentType::SchemaJson => templated_json_schema_check(doc, template_doc),
88+
ContentType::Json
89+
| ContentType::Cddl
9190
| ContentType::Cbor
9291
| ContentType::Css
9392
| ContentType::CssHandlebars
@@ -98,7 +97,7 @@ impl TemplateRule {
9897
| ContentType::Plain
9998
| ContentType::PlainHandlebars => {
10099
// TODO: not implemented yet
101-
true
100+
false
102101
},
103102
}
104103
};
@@ -183,7 +182,7 @@ mod tests {
183182
.with_metadata_field(SupportedField::Id(*template_ref.id()))
184183
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
185184
.with_metadata_field(SupportedField::Type(allowed_type))
186-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
185+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
187186
.with_content(json_schema)
188187
.build();
189188
provider.add_document(None, &doc).unwrap();
@@ -212,7 +211,7 @@ mod tests {
212211
.with_metadata_field(SupportedField::Id(*template_ref.id()))
213212
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
214213
.with_metadata_field(SupportedField::Type(allowed_type))
215-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
214+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
216215
.with_content(json_schema)
217216
.build();
218217
provider.add_document(None, &doc).unwrap();
@@ -238,7 +237,7 @@ mod tests {
238237
.with_metadata_field(SupportedField::Id(*template_ref.id()))
239238
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
240239
.with_metadata_field(SupportedField::Type(allowed_type))
241-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
240+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
242241
.with_content(json_schema)
243242
.build();
244243
provider.add_document(None, &doc).unwrap();
@@ -265,7 +264,7 @@ mod tests {
265264
.with_metadata_field(SupportedField::Id(*template_ref.id()))
266265
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
267266
.with_metadata_field(SupportedField::Type(allowed_type))
268-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
267+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
269268
.with_content(json_schema)
270269
.build();
271270
provider.add_document(None, &doc).unwrap();
@@ -293,7 +292,7 @@ mod tests {
293292
.with_metadata_field(SupportedField::Id(*template_ref.id()))
294293
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
295294
.with_metadata_field(SupportedField::Type(UuidV4::new().into()))
296-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
295+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
297296
.with_content(json_schema)
298297
.build();
299298
provider.add_document(None, &doc).unwrap();
@@ -321,7 +320,7 @@ mod tests {
321320
let doc = Builder::new()
322321
.with_metadata_field(SupportedField::Id(*template_ref.id()))
323322
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
324-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
323+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
325324
.with_content(json_schema)
326325
.build();
327326
provider.add_document(None, &doc).unwrap();
@@ -377,7 +376,7 @@ mod tests {
377376
.with_metadata_field(SupportedField::Id(*template_ref.id()))
378377
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
379378
.with_metadata_field(SupportedField::Type(allowed_type))
380-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
379+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
381380
.build();
382381
provider.add_document(None, &doc).unwrap();
383382
@@ -404,7 +403,7 @@ mod tests {
404403
.with_metadata_field(SupportedField::Id(*template_ref.id()))
405404
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
406405
.with_metadata_field(SupportedField::Type(allowed_type))
407-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
406+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
408407
.with_content(vec![1,2 ,3])
409408
.build();
410409
provider.add_document(None, &doc).unwrap();
@@ -478,7 +477,7 @@ mod tests {
478477
.with_metadata_field(SupportedField::Id(*template_ref.id()))
479478
.with_metadata_field(SupportedField::Ver(*template_ref.ver()))
480479
.with_metadata_field(SupportedField::Type(allowed_type))
481-
.with_metadata_field(SupportedField::ContentType(ContentType::Json))
480+
.with_metadata_field(SupportedField::ContentType(ContentType::SchemaJson))
482481
.with_content(json_schema)
483482
.build();
484483
provider.add_document(None, &doc).unwrap();

0 commit comments

Comments
 (0)