-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Fastly crate from
0.10.4
to 0.11.1
This updates the test fixtures to use the newly released `0.11.1` Fastly crate. When `fastly::acl` hostcalls were added in #438, the corresponding SDK support was not yet released. So #438 added tests using the still-unreleased-SDK, but put that code behind a compile-time gate ([here](#438 (comment))). This change removes that compile-time gate in `test-fixtures/src/bin/acl.rs`, effectively changing these tests from a no-op to running the desired test cases. A few other text-fixtures stopped compiling with the updated SDK, which I've tried to address: - `test-fixtures/src/bin/inspect.rs` cc/ @ulyssa - `test-fixtures/src/bin/kv_store.rs` cc/ @joeshaw
- Loading branch information
1 parent
a2b9fe3
commit 4af02d5
Showing
5 changed files
with
130 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,62 +1,56 @@ | ||
//! A guest program to test that acls works properly. | ||
use fastly::acl::Acl; | ||
use fastly::Error; | ||
use std::net::{Ipv4Addr, Ipv6Addr}; | ||
|
||
fn main() -> Result<(), Error> { | ||
// Temporary until fastly SDK is released which | ||
// includes the fastly::acl module. | ||
#[cfg(feature = "acl_hostcalls")] | ||
{ | ||
use fastly::acl::Acl; | ||
use std::net::{Ipv4Addr, Ipv6Addr}; | ||
|
||
match Acl::open("DOES-NOT-EXIST") { | ||
Err(fastly::acl::OpenError::AclNotFound) => { /* OK */ } | ||
Err(other) => panic!("expected error opening non-existant acl, got: {:?}", other), | ||
_ => panic!("expected error opening non-existant acl, got Ok"), | ||
} | ||
match Acl::open("DOES-NOT-EXIST") { | ||
Err(fastly::acl::OpenError::AclNotFound) => { /* OK */ } | ||
Err(other) => panic!("expected error opening non-existant acl, got: {:?}", other), | ||
_ => panic!("expected error opening non-existant acl, got Ok"), | ||
} | ||
|
||
let acl1 = Acl::open("my-acl-1")?; | ||
let acl1 = Acl::open("my-acl-1")?; | ||
|
||
match acl1.try_lookup(Ipv4Addr::new(192, 168, 1, 1).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "192.168.0.0/16"); | ||
assert!(lookup_match.is_block()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
match acl1.try_lookup(Ipv4Addr::new(23, 23, 23, 23).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "23.23.23.23/32"); | ||
assert!(lookup_match.is_allow()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
if let Some(lookup_match) = acl1.try_lookup(Ipv4Addr::new(100, 100, 100, 100).into())? { | ||
panic!("expected no match, got: {:?}", lookup_match); | ||
match acl1.try_lookup(Ipv4Addr::new(192, 168, 1, 1).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "192.168.0.0/16"); | ||
assert!(lookup_match.is_block()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
match acl1.try_lookup(Ipv4Addr::new(23, 23, 23, 23).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "23.23.23.23/32"); | ||
assert!(lookup_match.is_allow()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
if let Some(lookup_match) = acl1.try_lookup(Ipv4Addr::new(100, 100, 100, 100).into())? { | ||
panic!("expected no match, got: {:?}", lookup_match); | ||
} | ||
|
||
let acl2 = Acl::open("my-acl-2")?; | ||
let acl2 = Acl::open("my-acl-2")?; | ||
|
||
match acl2.try_lookup(Ipv6Addr::new(0x2000, 0, 0, 0, 0, 1, 2, 3).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "2000::/24"); | ||
assert!(lookup_match.is_block()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
match acl2.try_lookup(Ipv6Addr::new(0xFACE, 0, 2, 3, 4, 5, 6, 7).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "face::/16"); | ||
assert!(lookup_match.is_allow()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
if let Some(lookup_match) = | ||
acl2.try_lookup(Ipv6Addr::new(0xFADE, 1, 2, 3, 4, 5, 6, 7).into())? | ||
{ | ||
panic!("expected no match, got: {:?}", lookup_match); | ||
}; | ||
} | ||
match acl2.try_lookup(Ipv6Addr::new(0x2000, 0, 0, 0, 0, 1, 2, 3).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "2000::/24"); | ||
assert!(lookup_match.is_block()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
match acl2.try_lookup(Ipv6Addr::new(0xFACE, 0, 2, 3, 4, 5, 6, 7).into())? { | ||
Some(lookup_match) => { | ||
assert_eq!(lookup_match.prefix(), "face::/16"); | ||
assert!(lookup_match.is_allow()); | ||
} | ||
None => panic!("expected match"), | ||
}; | ||
if let Some(lookup_match) = | ||
acl2.try_lookup(Ipv6Addr::new(0xFADE, 1, 2, 3, 4, 5, 6, 7).into())? | ||
{ | ||
panic!("expected no match, got: {:?}", lookup_match); | ||
}; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,43 @@ | ||
//! A guest program to test that KV store works properly. | ||
use fastly::kv_store::{KVStore, KVStoreError::KVStoreNotFound}; | ||
use fastly::kv_store::{ | ||
KVStore, | ||
KVStoreError::{ItemNotFound, StoreNotFound}, | ||
}; | ||
|
||
fn main() { | ||
// Check we can't get a store that does not exist | ||
match KVStore::open("non_existant") { | ||
Err(KVStoreNotFound(_)) => {} | ||
Err(StoreNotFound(_)) => {} | ||
_ => panic!(), | ||
} | ||
|
||
let store_one = KVStore::open("store_one").unwrap().unwrap(); | ||
// Test that we can get data using the `data` config key | ||
assert_eq!( | ||
store_one.lookup_str("first").unwrap().unwrap(), | ||
store_one.lookup("first").unwrap().take_body().into_string(), | ||
"This is some data" | ||
); | ||
// Test that we can get data from a file using the `path` config key | ||
assert_eq!( | ||
store_one.lookup_str("second").unwrap().unwrap(), | ||
store_one | ||
.lookup("second") | ||
.unwrap() | ||
.take_body() | ||
.into_string(), | ||
"More data" | ||
); | ||
|
||
let mut empty_store = KVStore::open("empty_store").unwrap().unwrap(); | ||
let empty_store = KVStore::open("empty_store").unwrap().unwrap(); | ||
// Check that the value "bar" is not in the store | ||
assert_eq!(empty_store.lookup_str("bar"), Ok(None)); | ||
match empty_store.lookup("bar") { | ||
Err(ItemNotFound) => {} | ||
_ => panic!(), | ||
} | ||
empty_store.insert("bar", "foo").unwrap(); | ||
// Check that the value "bar" is now in the store | ||
assert_eq!(empty_store.lookup_str("bar").unwrap().unwrap(), "foo"); | ||
assert_eq!( | ||
empty_store.lookup("bar").unwrap().take_body().into_string(), | ||
"foo" | ||
); | ||
} |