WIP: change db roles based on HTTP basic auth headers
This commit is contained in:
+2
-2
@@ -18,7 +18,7 @@ import qualified Data.ByteString.Char8 as BS
|
||||
import Dbapi (app, AppConfig(..))
|
||||
|
||||
cfg :: AppConfig
|
||||
cfg = AppConfig "postgres://postgres:@localhost:5432/dbapi_test" 9000 "test/test.crt" "test/test.key"
|
||||
cfg = AppConfig "postgres://postgres:@localhost:5432/dbapi_test" 9000 "test/test.crt" "test/test.key" "postgres"
|
||||
|
||||
openConnection :: IO Connection
|
||||
openConnection = connectPostgreSQL' $ configDbUri cfg
|
||||
@@ -40,7 +40,7 @@ dbWithSchema action = withDatabaseConnection $ \c -> do
|
||||
appWithFixture :: ActionWith Application -> IO ()
|
||||
appWithFixture action = withDatabaseConnection $ \c -> do
|
||||
runRaw c "begin;"
|
||||
action $ app c
|
||||
action $ app c "postgres"
|
||||
rollback c
|
||||
|
||||
rangeHdrs :: ByteRange -> [Header]
|
||||
|
||||
@@ -11,12 +11,16 @@ import PgQuery (insert, addUser, signInRole)
|
||||
import Types (SqlRow(SqlRow))
|
||||
import TestTypes (fromList, incStr, incNullableStr, incInsert, incId)
|
||||
import Data.Map (toList)
|
||||
import Data.Monoid ((<>))
|
||||
import Data.String.Conversions (cs)
|
||||
import Control.Arrow
|
||||
|
||||
import SpecHelper(dbWithSchema)
|
||||
|
||||
quickALQuery :: IConnection conn => conn -> String -> [SqlValue] -> IO [[(String, SqlValue)]]
|
||||
quickALQuery :: IConnection conn => conn ->
|
||||
String ->
|
||||
[SqlValue] ->
|
||||
IO [[(String, SqlValue)]]
|
||||
quickALQuery conn q bind = do
|
||||
sth <- prepare conn q
|
||||
_ <- execute sth bind
|
||||
@@ -61,7 +65,7 @@ spec = around dbWithSchema $ do
|
||||
r2 <- signInRole user pass conn
|
||||
r2 `shouldBe` Just role
|
||||
|
||||
r3 <- signInRole user (pass++"crap") conn
|
||||
r3 <- signInRole user (pass <> "crap") conn
|
||||
r3 `shouldBe` Nothing
|
||||
|
||||
it "will not add a user with an unknown role" $ \conn -> do
|
||||
|
||||
Reference in New Issue
Block a user