Skip to content

Commit

Permalink
update for cedar#450 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdisselkoen authored Nov 17, 2023
1 parent f8d502b commit 4777fd9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cedar
10 changes: 5 additions & 5 deletions cedar-dafny/difftest/main.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module difftest.main {
const entitytypeFromProdJson :=
sumDeserializer(
map[
"Concrete" := j => var n :- nameFromProdJson(j); Ok(EntityType(n)),
"Specified" := j => var n :- nameFromProdJson(j); Ok(EntityType(n)),
"Unspecified" := _ => Ok(EntityType.UNSPECIFIED)
])

Expand Down Expand Up @@ -293,11 +293,11 @@ module difftest.main {
}

// In the production engine, `EntityUIDEntry` is the data type for a request
// field that is either a "concrete" EntityUID or "unknown" (for partial
// field that is either a "known" EntityUID or "unknown" (for partial
// evaluation). We currently don't support partial evaluation, so we just
// translate the "concrete" variant to an EntityUID.
// translate the "known" variant to an EntityUID.
const entityUIDEntryFromProdJson :=
sumDeserializer(map["Concrete" := entityUIDFromProdJson])
sumDeserializer(map["Known" := entityUIDFromProdJson])

function getEntityUIDEntryField(request: Json, f: string): FromProdResult<EntityUID> {
deserializeField(request, f, entityUIDEntryFromProdJson)
Expand Down Expand Up @@ -532,7 +532,7 @@ module difftest.main {
const entitytypeFromProdJsonOption :=
sumDeserializer(
map[
"Concrete" := j => var n :- nameFromProdJson(j); Ok(Some(EntityType(n))),
"Specified" := j => var n :- nameFromProdJson(j); Ok(Some(EntityType(n))),
"Unspecified" := _ => Ok(None)
])

Expand Down
4 changes: 2 additions & 2 deletions cedar-drt/fuzz/src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ pub fn dump<'a>(
fn dump_request_var(var: &EntityUIDEntry) -> Option<String> {
match var {
EntityUIDEntry::Unknown => None,
EntityUIDEntry::Concrete(euid) => match euid.entity_type() {
EntityUIDEntry::Known(euid) => match euid.entity_type() {
cedar_policy_core::ast::EntityType::Unspecified => None,
cedar_policy_core::ast::EntityType::Concrete(_) => Some(euid.to_string()),
cedar_policy_core::ast::EntityType::Specified(_) => Some(euid.to_string()),
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions cedar-drt/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ fn test_run_auth_test() {

let java_def_engine =
JavaDefinitionalEngine::new().expect("failed to create definitional engine");
let principal = ast::EntityUIDEntry::Concrete(std::sync::Arc::new(
let principal = ast::EntityUIDEntry::Known(std::sync::Arc::new(
EntityUID::with_eid_and_type("User", "alice").unwrap(),
));
let action = ast::EntityUIDEntry::Concrete(std::sync::Arc::new(
let action = ast::EntityUIDEntry::Known(std::sync::Arc::new(
EntityUID::with_eid_and_type("Action", "view").unwrap(),
));
let resource = ast::EntityUIDEntry::Concrete(std::sync::Arc::new(
let resource = ast::EntityUIDEntry::Known(std::sync::Arc::new(
EntityUID::with_eid_and_type("Photo", "vacation").unwrap(),
));
let query = ast::Request::new_with_unknowns(
Expand Down
6 changes: 3 additions & 3 deletions cedar-policy-generators/src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl From<Entities> for Hierarchy {
let mut uids_by_type: HashMap<ast::Name, HashSet<ast::EntityUID>> = HashMap::new();
for e in entities.iter() {
let etype = match e.uid().entity_type() {
ast::EntityType::Concrete(name) => name.clone(),
ast::EntityType::Specified(name) => name.clone(),
ast::EntityType::Unspecified => {
panic!("didn't expect unspecified entity in Entities")
}
Expand Down Expand Up @@ -411,7 +411,7 @@ impl<'a, 'u> HierarchyGenerator<'a, 'u> {
entity_types
.into_iter()
.filter_map(|ty| match ty {
ast::EntityType::Concrete(name) => Some(name),
ast::EntityType::Specified(name) => Some(name),
ast::EntityType::Unspecified => None,
})
.collect()
Expand Down Expand Up @@ -495,7 +495,7 @@ impl<'a, 'u> HierarchyGenerator<'a, 'u> {
.entities()
.map(|e| e.uid())
.map(|uid| {
let ast::EntityType::Concrete(name) = uid.entity_type() else {
let ast::EntityType::Specified(name) = uid.entity_type() else {
// `entity_types` was generated in such a way as to never produce
// unspecified entities
panic!("should not be possible to generate an unspecified entity")
Expand Down
10 changes: 5 additions & 5 deletions cedar-policy-generators/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ pub(crate) fn build_qualified_entity_type_name(
name: ast::Id,
) -> ast::Name {
match build_qualified_entity_type(namespace, Some(name)) {
ast::EntityType::Concrete(type_name) => type_name,
ast::EntityType::Specified(type_name) => type_name,
ast::EntityType::Unspecified => {
panic!("Should not have built an unspecified type from `Some(name)`.")
}
Expand Down Expand Up @@ -378,8 +378,8 @@ fn build_qualified_entity_type(
) -> ast::EntityType {
match basename {
Some(basename) => match namespace {
None => ast::EntityType::Concrete(ast::Name::unqualified_name(basename)),
Some(ns) => ast::EntityType::Concrete(ast::Name::type_in_namespace(basename, ns)),
None => ast::EntityType::Specified(ast::Name::unqualified_name(basename)),
Some(ns) => ast::EntityType::Specified(ast::Name::type_in_namespace(basename, ns)),
},
None => ast::EntityType::Unspecified,
}
Expand Down Expand Up @@ -854,7 +854,7 @@ impl Schema {
) -> Result<ast::EntityUID> {
let ty = build_qualified_entity_type(self.namespace().cloned(), ty_name);
match ty {
ast::EntityType::Concrete(ty) => self
ast::EntityType::Specified(ty) => self
.exprgenerator(hierarchy)
.arbitrary_uid_with_type(&ty, u),
ast::EntityType::Unspecified => Ok(ast::EntityUID::unspecified_from_eid(
Expand Down Expand Up @@ -892,7 +892,7 @@ impl Schema {
ast::EntityType::Unspecified => {
panic!("should not be possible to generate an unspecified entity")
}
ast::EntityType::Concrete(name) => {
ast::EntityType::Specified(name) => {
Some(entity_type_name_to_schema_type_variant(&name))
}
}
Expand Down

0 comments on commit 4777fd9

Please sign in to comment.