Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ooniauth-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ooniauth_py"
version = "0.1.3"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
6 changes: 5 additions & 1 deletion ooniauth-py/ooniauth_py.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ class UserState:
"""

def make_submit_request(
self, probe_cc: str, probe_asn: str, emission_date: builtins.int
self,
probe_cc: str,
probe_asn: str,
age_range: tuple[builtins.int, builtins.int],
measurement_count_range: tuple[builtins.int, builtins.int],
) -> SubmitRequest: ...
def handle_submit_response(self, response: str) -> None:
r"""
Expand Down
25 changes: 17 additions & 8 deletions ooniauth-py/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ impl UserState {
py: Python<'_>,
probe_cc: Py<PyString>,
probe_asn: Py<PyString>,
emission_date: u32,
age_range: (u32, u32),
measurement_count_range: (u32, u32),
) -> OoniResult<SubmitRequest> {
let probe_cc = probe_cc.to_str(py).expect("unable to get string");
let probe_asn = probe_asn.to_str(py).expect("unable to get string");
Expand All @@ -239,8 +240,8 @@ impl UserState {
&mut rng,
probe_cc.into(),
probe_asn.into(),
(emission_date - 30)..(emission_date + 1),
0..100,
age_range.0..age_range.1,
measurement_count_range.0..measurement_count_range.1,
)?;

self.submit_client_state = Some(client_state);
Expand Down Expand Up @@ -357,12 +358,18 @@ mod tests {
let cc = PyString::new(py, "VE");
let asn = PyString::new(py, "AS1234");
let today = ServerState::today();
let age_range = PyList::new(py, vec![today - 30, today + 1]).unwrap();
let msm_range = PyList::new(py, vec![0, 100]).unwrap();
let submit_req = client
.make_submit_request(py, cc.clone().into(), asn.clone().into(), today)
.make_submit_request(
py,
cc.clone().into(),
asn.clone().into(),
(today - 30, today + 1),
(0, 100),
)
.unwrap();

let age_range = PyList::new(py, vec![today - 30, today + 1]).unwrap();
let msm_range = PyList::new(py, vec![0, 100]).unwrap();
assert!(server
.handle_submit_request(
py,
Expand Down Expand Up @@ -455,7 +462,8 @@ mod tests {
py,
probe_cc.clone_ref(py),
probe_asn.clone_ref(py),
ServerState::today(),
(today - 30, today + 1),
(0, 100),
)
.expect("Unable to make submit request");

Expand Down Expand Up @@ -499,7 +507,8 @@ mod tests {
py,
probe_cc.clone_ref(py),
probe_asn.clone_ref(py),
ServerState::today(),
(today - 30, today + 1),
(0, 100),
)
.expect("Unable to make submit request");

Expand Down
Loading