Correct openapi ignore-privs table comments
This commit is contained in:
committed by
Steve Chavez
parent
67c2ed7c62
commit
0961a587c0
@@ -466,7 +466,7 @@ allTables =
|
|||||||
SELECT
|
SELECT
|
||||||
n.nspname AS table_schema,
|
n.nspname AS table_schema,
|
||||||
c.relname AS table_name,
|
c.relname AS table_name,
|
||||||
NULL AS table_description,
|
d.description AS table_description,
|
||||||
(
|
(
|
||||||
c.relkind = 'r'
|
c.relkind = 'r'
|
||||||
OR (
|
OR (
|
||||||
@@ -521,6 +521,7 @@ allTables =
|
|||||||
) AS deletable
|
) AS deletable
|
||||||
FROM pg_class c
|
FROM pg_class c
|
||||||
JOIN pg_namespace n ON n.oid = c.relnamespace
|
JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||||
|
LEFT JOIN pg_catalog.pg_description as d on d.objoid = c.oid and d.objsubid = 0
|
||||||
WHERE c.relkind IN ('v','r','m','f')
|
WHERE c.relkind IN ('v','r','m','f')
|
||||||
AND n.nspname NOT IN ('pg_catalog', 'information_schema')
|
AND n.nspname NOT IN ('pg_catalog', 'information_schema')
|
||||||
ORDER BY table_schema, table_name |]
|
ORDER BY table_schema, table_name |]
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
module Feature.IgnorePrivOpenApiSpec where
|
|
||||||
|
|
||||||
import Control.Lens ((^?))
|
|
||||||
|
|
||||||
import Data.Aeson.Lens
|
|
||||||
import Data.Aeson.QQ
|
|
||||||
|
|
||||||
import Network.HTTP.Types
|
|
||||||
import Network.Wai (Application)
|
|
||||||
import Network.Wai.Test (SResponse (..))
|
|
||||||
|
|
||||||
import Test.Hspec hiding (pendingWith)
|
|
||||||
import Test.Hspec.Wai
|
|
||||||
|
|
||||||
import Protolude hiding (get)
|
|
||||||
import SpecHelper
|
|
||||||
|
|
||||||
spec :: SpecWith ((), Application)
|
|
||||||
spec = describe "OpenAPI Ignore ACL" $ do
|
|
||||||
it "root path returns a valid openapi spec" $ do
|
|
||||||
validateOpenApiResponse [("Accept", "application/openapi+json")]
|
|
||||||
request methodHead "/" (acceptHdrs "application/openapi+json") ""
|
|
||||||
`shouldRespondWith` "" { matchStatus = 200 }
|
|
||||||
|
|
||||||
describe "table" $ do
|
|
||||||
|
|
||||||
it "includes privileged table even if user does not have permission" $ do
|
|
||||||
r <- simpleBody <$> get "/"
|
|
||||||
let tableTag = r ^? key "paths" . key "/authors_only"
|
|
||||||
. key "post" . key "tags"
|
|
||||||
. nth 0
|
|
||||||
|
|
||||||
liftIO $ tableTag `shouldBe` Just [aesonQQ|"authors_only"|]
|
|
||||||
|
|
||||||
it "only includes tables that belong to another schema if the Accept-Profile header is used" $ do
|
|
||||||
r1 <- simpleBody <$> get "/"
|
|
||||||
let tableKey1 = r1 ^? key "paths" . key "/children"
|
|
||||||
|
|
||||||
liftIO $ tableKey1 `shouldBe` Nothing
|
|
||||||
|
|
||||||
r2 <- simpleBody <$> request methodGet "/" [("Accept-Profile", "v1")] ""
|
|
||||||
let tableKey2 = r2 ^? key "paths" . key "/children"
|
|
||||||
|
|
||||||
liftIO $ tableKey2 `shouldNotBe` Nothing
|
|
||||||
|
|
||||||
describe "RPC" $ do
|
|
||||||
|
|
||||||
it "includes privileged function even if user does not have permission" $ do
|
|
||||||
r <- simpleBody <$> get "/"
|
|
||||||
let funcTag = r ^? key "paths" . key "/rpc/privileged_hello"
|
|
||||||
. key "post" . key "tags"
|
|
||||||
. nth 0
|
|
||||||
|
|
||||||
liftIO $ funcTag `shouldBe` Just [aesonQQ|"(rpc) privileged_hello"|]
|
|
||||||
|
|
||||||
it "only includes functions that belong to another schema if the Accept-Profile header is used" $ do
|
|
||||||
r1 <- simpleBody <$> get "/"
|
|
||||||
let funcKey1 = r1 ^? key "paths" . key "/rpc/get_parents_below"
|
|
||||||
|
|
||||||
liftIO $ funcKey1 `shouldBe` Nothing
|
|
||||||
|
|
||||||
r2 <- simpleBody <$> request methodGet "/" [("Accept-Profile", "v1")] ""
|
|
||||||
let funcKey2 = r2 ^? key "paths" . key "/rpc/get_parents_below"
|
|
||||||
|
|
||||||
liftIO $ funcKey2 `shouldNotBe` Nothing
|
|
||||||
@@ -43,6 +43,17 @@ spec = describe "OpenAPI Ignore Privileges" $ do
|
|||||||
|
|
||||||
liftIO $ tableKey2 `shouldNotBe` Nothing
|
liftIO $ tableKey2 `shouldNotBe` Nothing
|
||||||
|
|
||||||
|
it "includes comments on tables" $ do
|
||||||
|
r <- simpleBody <$> get "/"
|
||||||
|
|
||||||
|
let grandChildGet s = key "paths" . key "/grandchild_entities" . key "get" . key s
|
||||||
|
grandChildGetSummary = r ^? grandChildGet "summary"
|
||||||
|
grandChildGetDescription = r ^? grandChildGet "description"
|
||||||
|
|
||||||
|
liftIO $ do
|
||||||
|
grandChildGetSummary `shouldBe` Just "grandchild_entities summary"
|
||||||
|
grandChildGetDescription `shouldBe` Just "grandchild_entities description\nthat spans\nmultiple lines"
|
||||||
|
|
||||||
describe "RPC" $ do
|
describe "RPC" $ do
|
||||||
|
|
||||||
it "includes privileged function even if user does not have permission" $ do
|
it "includes privileged function even if user does not have permission" $ do
|
||||||
|
|||||||
Reference in New Issue
Block a user