Skip to content

Commit

Permalink
fix: missing certification object in CEL expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanosdev committed Dec 5, 2023
1 parent e7eb8ff commit 1ee5f7c
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 108 deletions.
2 changes: 2 additions & 0 deletions packages/ic-http-certification/src/cel/create_cel_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ fn create_default_cel_expr(certification: &Option<DefaultCertification>) -> Stri
match certification {
None => cel_expr.push_str("no_certification:Empty{}"),
Some(certification) => {
cel_expr.push_str("certification:Certification{");
create_request_cel_expr(&mut cel_expr, certification.request_certification.as_ref());
create_response_cel_expr(&mut cel_expr, &certification.response_certification);
cel_expr.push_str("}");
}
}

Expand Down
236 changes: 128 additions & 108 deletions packages/ic-http-certification/src/cel/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ pub(super) fn no_request_response_inclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
no_request_certification: Empty {},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: [
"Cache-Control",
"ETag",
"Content-Length",
"Content-Type",
"Content-Encoding"
]
certification: Certification {
no_request_certification: Empty {},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: [
"Cache-Control",
"ETag",
"Content-Length",
"Content-Type",
"Content-Encoding"
]
}
}
}
}
Expand All @@ -38,14 +40,16 @@ pub(super) fn no_request_response_exclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
no_request_certification: Empty {},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: [
"Date",
"Cookie",
"Set-Cookie"
]
certification: Certification {
no_request_certification: Empty {},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: [
"Date",
"Cookie",
"Set-Cookie"
]
}
}
}
}
Expand All @@ -58,10 +62,12 @@ pub(super) fn no_request_empty_response_inclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
no_request_certification: Empty {},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: []
certification: Certification {
no_request_certification: Empty {},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: []
}
}
}
}
Expand All @@ -74,10 +80,12 @@ pub(super) fn no_request_empty_response_exclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
no_request_certification: Empty {},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: []
certification: Certification {
no_request_certification: Empty {},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: []
}
}
}
}
Expand All @@ -90,27 +98,29 @@ pub(super) fn include_request_response_header_inclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: [
"Cache-Control",
"ETag",
"Content-Length",
"Content-Type",
"Content-Encoding"
certification: Certification {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: [
"Cache-Control",
"ETag",
"Content-Length",
"Content-Type",
"Content-Encoding"
]
}
}
}
}
Expand All @@ -123,25 +133,27 @@ pub(super) fn include_request_response_header_exclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: [
"Date",
"Cookie",
"Set-Cookie"
certification: Certification {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: [
"Date",
"Cookie",
"Set-Cookie"
]
}
}
}
}
Expand All @@ -154,21 +166,23 @@ pub(super) fn include_request_empty_response_inclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: []
certification: Certification {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: []
}
}
}
}
Expand All @@ -181,21 +195,23 @@ pub(super) fn include_request_empty_response_exclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: []
certification: Certification {
request_certification: RequestCertification {
certified_request_headers: [
"Accept",
"Accept-Encoding",
"If-Match"
],
certified_query_parameters: [
"foo",
"bar",
"baz"
]
},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: []
}
}
}
}
Expand All @@ -208,13 +224,15 @@ pub(super) fn empty_request_response_inclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
request_certification: RequestCertification {
certified_request_headers: [],
certified_query_parameters: []
},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: []
certification: Certification {
request_certification: RequestCertification {
certified_request_headers: [],
certified_query_parameters: []
},
response_certification: ResponseCertification {
certified_response_headers: ResponseHeaderList {
headers: []
}
}
}
}
Expand All @@ -227,13 +245,15 @@ pub(super) fn empty_request_response_exclusions_cel() -> String {
remove_whitespace(
r#"default_certification(
ValidationArgs {
request_certification: RequestCertification {
certified_request_headers: [],
certified_query_parameters: []
},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: []
certification: Certification {
request_certification: RequestCertification {
certified_request_headers: [],
certified_query_parameters: []
},
response_certification: ResponseCertification {
response_header_exclusions: ResponseHeaderList {
headers: []
}
}
}
}
Expand Down

0 comments on commit 1ee5f7c

Please sign in to comment.