Skip to content

Commit

Permalink
test: update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
divarvel committed Jul 3, 2024
1 parent b58fa45 commit ed6c765
Show file tree
Hide file tree
Showing 31 changed files with 1,968 additions and 724 deletions.
68 changes: 45 additions & 23 deletions biscuit/test/Spec/SampleReader.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Spec.SampleReader where

import Control.Arrow ((&&&))
Expand Down Expand Up @@ -151,21 +154,45 @@ data BlockDesc
deriving stock (Eq, Show, Generic)
deriving anyclass (FromJSON, ToJSON)

data FactSet
= FactSet
{ origin :: [Maybe Integer]
, facts :: [Text]
}
deriving stock (Eq, Show, Generic)
deriving anyclass (FromJSON, ToJSON)

data RuleSet
= RuleSet
{ origin :: Maybe Integer
, rules :: [Text]
}
deriving stock (Eq, Show, Generic)
deriving anyclass (FromJSON, ToJSON)

data CheckSet
= CheckSet
{ origin :: Maybe Integer
, checks :: [Text]
}
deriving stock (Eq, Show, Generic)
deriving anyclass (FromJSON, ToJSON)

data WorldDesc
= WorldDesc
{ facts :: [Text]
, rules :: [Text]
, checks :: [Text]
{ facts :: [FactSet]
, rules :: [RuleSet]
, checks :: [CheckSet]
, policies :: [Text]
}
deriving stock (Eq, Show, Generic)
deriving anyclass (FromJSON, ToJSON)

instance Semigroup WorldDesc where
a <> b = WorldDesc
{ facts = facts a <> facts b
, rules = rules a <> rules b
, checks = checks a <> checks b
{ facts = a.facts <> b.facts
, rules = a.rules <> b.rules
, checks = a.checks <> b.checks
, policies = policies a <> policies b
}

Expand Down Expand Up @@ -307,12 +334,7 @@ mkTestCaseFromBiscuit title filename biscuit authorizers = do
mkValidation authorizer = do
Right success <- authorizeBiscuit biscuit authorizer
pure ValidationR
{ world = Just $ WorldDesc
{ facts = []
, rules = []
, checks = []
, policies = []
}
{ world = Just mempty
, result = Ok 0
, authorizer_code = authorizer
, revocation_ids = encodeHex <$> toList (getRevocationIds biscuit)
Expand Down
Loading

0 comments on commit ed6c765

Please sign in to comment.