Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

bug: Add additional verification checks. #80

Merged
merged 6 commits into from
May 19, 2021
Merged

Conversation

jrconlin
Copy link
Member

Closes #22

Description

Perform additional field validation checks for impression_url to ensure required values are present.

Testing

Test included

Issue(s)

Closes #22

@jrconlin jrconlin requested a review from a team May 13, 2021 23:48
App::new().route(
fn init_mock_adm(response: String) -> (dev::Server, SocketAddr) {
let server = HttpServer::new(move || {
App::new().data(response.clone()).route(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's gross.
Yes, it works.

return Err(HandlerErrorKind::UnexpectedHost(species, host).into());
}
Ok(())
Ok(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is the bool needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. it's used as a bool in check_click.

src/adm.rs Outdated
tags.add_extra("url", &url);
// Check the required fields are present for the `click_url`
// pg 15 of 5.7.21 spec.
let mut check_keys = vec![
Copy link
Member

@pjenvey pjenvey May 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't need to_owned on these string values due to String having PartialEq<&str> -- it could also be a plain array instead of vec and could even be static, even w/ the sorting (via lazy_static)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g.

lazy_static! {
    static ref CLICK_PARAMS: [&'static str; 5] = {
        let mut params = [
            "ctag",
            "version",
            "key",
            "ci",
            "aespFlag",
        ];
        params.sort();
        params
    };
}
query_keys == *CLICK_PARAMS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but I wanted to keep things together as much as possible, and lazy_static! doesn't want to be in a fn.

src/adm.rs Outdated
"ci".to_owned(),
"aespFlag".to_owned(),
];
check_keys.sort();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the latest API doc has one more probably new addition here, an optional "click-status" field that we should allow if present. It's only for clicks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I'll add a required and optional param check.

@pjenvey
Copy link
Member

pjenvey commented May 18, 2021

Also we can fix these after merging if they'll cause 3-PRs-in merge hell

@jrconlin
Copy link
Member Author

I've bought a bungalow in merge hell.

The sunsets are nice

if you ignore the wailing and gnashing of teeth.

return Err(HandlerErrorKind::InvalidHost(species, url.to_string()).into());
}
};
check_url(parsed, species, &filter.impression_hosts)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, we forgot one more thing: we should require an id param on impression_urls

@jrconlin jrconlin requested a review from pjenvey May 19, 2021 20:55
@jrconlin jrconlin merged commit 5e52f24 into main May 19, 2021
@jrconlin jrconlin deleted the feat/22-addl-check branch May 19, 2021 22:28
Trinaa pushed a commit that referenced this pull request Jun 13, 2022
…astapi-0.68.2

Bump fastapi from 0.68.1 to 0.68.2 in /partner
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.3 Validate AdM Tile data
2 participants