Skip to content

Commit

Permalink
fix e2e, enum lint & imporved dbg print
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Nowak-Liebiediew committed Nov 14, 2023
1 parent 77202d7 commit 124e7dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
15 changes: 5 additions & 10 deletions e2e/tests-dfx/assetscanister.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1484,38 +1484,33 @@ CHERRIES" "$stdout"
"match": "nevermatchme",
"cache": {
"max_age": 2000
},
"allow_raw_access": true
}
}'
assert_match 'WARN: 4 unmatched configurations in .*/src/e2e_project_frontend/assets/somedir/.ic-assets.json config file:'
assert_contains 'WARN: {
"match": "nevermatchme",
"headers": {},
"ignore": false,
"allow_raw_access": true
"ignore": false
}
WARN: {
"match": "nevermatchmetoo",
"headers": {},
"ignore": false,
"allow_raw_access": true
"ignore": false
}
WARN: {
"match": "non-matcher",
"headers": {
"x-header": "x-value"
},
"ignore": false,
"allow_raw_access": true
"ignore": false
}'
# splitting this up into two checks, because the order is different on macos vs ubuntu
assert_contains 'WARN: {
"match": "/thanks-for-not-stripping-forward-slash",
"headers": {
"x-header": "x-value"
},
"ignore": false,
"allow_raw_access": true
"ignore": false
}'
}

Expand Down
23 changes: 9 additions & 14 deletions src/canisters/frontend/ic-asset/src/asset/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,14 @@ pub struct AssetConfigRule {
allow_raw_access: Option<bool>,
}

#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
#[derive(Deserialize, Debug, Clone, PartialEq, Eq, Default)]
enum Maybe<T> {
Null,
#[default]
Absent,
Value(T),
}

impl<T> Default for Maybe<T> {
fn default() -> Self {
Self::Absent
}
}

impl AssetConfigRule {
fn applies(&self, canonical_path: &Path) -> bool {
// TODO: better dot files/dirs handling, awaiting upstream changes:
Expand Down Expand Up @@ -421,12 +416,6 @@ mod rule_utils {
s.push_str(&format!(" - HTTP cache max-age: {}\n", max_age));
}
}
if let Some(aliasing) = self.enable_aliasing {
s.push_str(&format!(
" - URL path aliasing: {}\n",
if aliasing { "enabled" } else { "disabled" }
));
}
if let Some(allow_raw_access) = self.allow_raw_access {
s.push_str(&format!(
" - enable raw access: {}\n",
Expand All @@ -437,6 +426,12 @@ mod rule_utils {
}
));
}
if let Some(aliasing) = self.enable_aliasing {
s.push_str(&format!(
" - URL path aliasing: {}\n",
if aliasing { "enabled" } else { "disabled" }
));
}
if let Some(ref headers) = self.headers {
for (key, value) in headers {
s.push_str(&format!(
Expand Down Expand Up @@ -937,7 +932,7 @@ mod with_tempdir {
AssetConfig {
allow_raw_access: Some(true),
..Default::default()
},
}
);
}

Expand Down

0 comments on commit 124e7dc

Please sign in to comment.