-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add device detection hostcall (#330)
* Add hostcall for device_detection. This is closely patterned on the geolocation hostcall. The new test that executes the hostcall needs a new SDK, so this will be followed by a separate commit that comments it out. That can be reverted once the new SDK is available. * device_detection: Temporarily comment out tests that need new SDK. These tests depend on a new SDK for the device_detection hostcall, comment them out for now. This is in its own commit to make it easy to revert. * Minor changes from cargo fmt. * Fix copy/pasted identifier.
- Loading branch information
1 parent
6e60112
commit c4531d3
Showing
21 changed files
with
640 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// use crate::common::{Test, TestResult}; | ||
// use hyper::{body::to_bytes, StatusCode}; | ||
|
||
// #[tokio::test(flavor = "multi_thread")] | ||
// async fn json_device_detection_lookup_works() -> TestResult { | ||
// const FASTLY_TOML: &str = r#" | ||
// name = "json-device-detection-lookup" | ||
// description = "json device detection lookup test" | ||
// authors = ["Test User <[email protected]>"] | ||
// language = "rust" | ||
// [local_server] | ||
// [local_server.device_detection] | ||
// file = "../test-fixtures/data/device-detection-mapping.json" | ||
// format = "json" | ||
// "#; | ||
|
||
// let resp = Test::using_fixture("device-detection-lookup.wasm") | ||
// .using_fastly_toml(FASTLY_TOML)? | ||
// .against_empty() | ||
// .await?; | ||
|
||
// assert_eq!(resp.status(), StatusCode::OK); | ||
// assert!(to_bytes(resp.into_body()) | ||
// .await | ||
// .expect("can read body") | ||
// .to_vec() | ||
// .is_empty()); | ||
|
||
// Ok(()) | ||
// } | ||
|
||
// #[tokio::test(flavor = "multi_thread")] | ||
// async fn inline_toml_device_detection_lookup_works() -> TestResult { | ||
// const FASTLY_TOML: &str = r#" | ||
// name = "inline-toml-device-detection-lookup" | ||
// description = "inline toml device detection lookup test" | ||
// authors = ["Test User <[email protected]>"] | ||
// language = "rust" | ||
// [local_server] | ||
// [local_server.device_detection] | ||
// format = "inline-toml" | ||
// [local_server.device_detection.user_agents] | ||
// [local_server.device_detection.user_agents."Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 [FBAN/FBIOS;FBAV/8.0.0.28.18;FBBV/1665515;FBDV/iPhone4,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/7.0.4;FBSS/2; FBCR/Telekom.de;FBID/phone;FBLC/de_DE;FBOP/5]"] | ||
// user_agent = {} | ||
// os = {} | ||
// device = {name = "iPhone", brand = "Apple", model = "iPhone4,1", hwtype = "Mobile Phone", is_ereader = false, is_gameconsole = false, is_mediaplayer = false, is_mobile = true, is_smarttv = false, is_tablet = false, is_tvplayer = false, is_desktop = false, is_touchscreen = true } | ||
// [local_server.device_detection.user_agents."ghosts-app/1.0.2.1 (ASUSTeK COMPUTER INC.; X550CC; Windows 8 (X86); en)"] | ||
// user_agent = {} | ||
// os = {} | ||
// device = {name = "Asus TeK", brand = "Asus", model = "TeK", is_desktop = false } | ||
// "#; | ||
|
||
// let resp = Test::using_fixture("device-detection-lookup.wasm") | ||
// .using_fastly_toml(FASTLY_TOML)? | ||
// .against_empty() | ||
// .await?; | ||
|
||
// assert_eq!(resp.status(), StatusCode::OK); | ||
// assert!(to_bytes(resp.into_body()) | ||
// .await | ||
// .expect("can read body") | ||
// .to_vec() | ||
// .is_empty()); | ||
|
||
// Ok(()) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.