Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
caafe0e7
Commit
caafe0e7
authored
Sep 28, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More progress
parent
d02d3d8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
3 deletions
+10
-3
Auth.hs
src/Gargantext/API/Admin/Auth.hs
+2
-2
Private.hs
test/Test/API/Private.hs
+6
-1
Utils.hs
test/Test/Utils.hs
+2
-0
No files found.
src/Gargantext/API/Admin/Auth.hs
View file @
caafe0e7
...
...
@@ -115,8 +115,8 @@ auth :: (HasSettings env, CmdCommon env, HasJoseError err)
auth
(
AuthRequest
u
p
)
=
do
checkAuthRequest'
<-
checkAuthRequest
u
p
case
checkAuthRequest'
of
InvalidUser
->
pure
$
AuthResponse
Nothing
(
Just
$
AuthInvalid
"Invalid user"
)
InvalidPassword
->
pure
$
AuthResponse
Nothing
(
Just
$
AuthInvalid
"Invalid password"
)
InvalidUser
->
pure
$
AuthResponse
Nothing
(
Just
$
AuthInvalid
"Invalid user
name or password
"
)
InvalidPassword
->
pure
$
AuthResponse
Nothing
(
Just
$
AuthInvalid
"Invalid
username or
password"
)
Valid
to
trId
uId
->
pure
$
AuthResponse
(
Just
$
AuthValid
to
trId
uId
)
Nothing
--type instance BasicAuthCfg = BasicAuthData -> IO (AuthResult AuthenticatedUser)
...
...
test/Test/API/Private.hs
View file @
caafe0e7
...
...
@@ -26,7 +26,6 @@ import Test.Database.Types
import
Test.Hspec
import
Test.Hspec.Wai
hiding
(
pendingWith
)
import
Test.Hspec.Wai.Internal
(
withApplication
)
import
Test.Hspec.Wai.JSON
import
qualified
Data.Text.Encoding
as
TE
import
qualified
Network.Wai.Handler.Warp
as
Wai
import
qualified
Servant.Auth.Client
as
SA
...
...
@@ -121,3 +120,9 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
withValidLogin
port
"alice"
(
GargPassword
"alice"
)
$
\
token
->
do
protected
token
"GET"
(
mkUrl
port
"/node/8"
)
""
`
shouldRespondWith'
`
[
jsonFragment
|
{"id":8,"user_id":2,"name":"alice" }
|]
it
"forbids 'alice' to see others node private info"
$
\
((
_testEnv
,
port
),
app
)
->
do
withApplication
app
$
do
withValidLogin
port
"alice"
(
GargPassword
"alice"
)
$
\
token
->
do
protected
token
"GET"
(
mkUrl
port
"/node/1"
)
""
`
shouldRespondWith
`
403
test/Test/Utils.hs
View file @
caafe0e7
...
...
@@ -27,6 +27,8 @@ pending reason act = act `catch` (\(e :: SomeException) -> do
putStrLn
$
"PENDING: "
<>
reason
putStrLn
(
displayException
e
))
-- | Similar to 'json' from the 'Test.Hspec.Wai.JSON' package,
-- but allows matching on a /fragment/ of the body.
jsonFragment
::
QuasiQuoter
jsonFragment
=
QuasiQuoter
{
quoteExp
=
\
input
->
[
|
fromValue
$
(
quoteExp
aesonQQ
input
)
|
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment