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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
ec271ca6
Verified
Commit
ec271ca6
authored
Jan 10, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] fix tests
parent
786d8c40
Pipeline
#5483
passed with stages
in 126 minutes and 24 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
21 deletions
+10
-21
Share.hs
src/Gargantext/API/Node/Share.hs
+1
-1
Authentication.hs
test/Test/API/Authentication.hs
+7
-14
Errors.hs
test/Test/API/Errors.hs
+1
-1
Private.hs
test/Test/API/Private.hs
+1
-5
No files found.
src/Gargantext/API/Node/Share.hs
View file @
ec271ca6
...
...
@@ -38,7 +38,7 @@ import Test.QuickCheck.Arbitrary
------------------------------------------------------------------------
data
ShareNodeParams
=
ShareTeamParams
{
username
::
Text
}
|
SharePublicParams
{
node_id
::
NodeId
}
|
SharePublicParams
{
node_id
::
NodeId
}
deriving
(
Generic
)
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
...
...
test/Test/API/Authentication.hs
View file @
ec271ca6
...
...
@@ -59,24 +59,17 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
let
authPayload
=
AuthRequest
"alice"
(
GargPassword
"alice"
)
result0
<-
runClientM
(
auth_api
authPayload
)
(
clientEnv
port
)
let
result
=
over
(
_Right
.
authRes_
valid
.
_Just
.
authVal_
token
)
(
const
cannedToken
)
result0
let
result
=
over
(
_Right
.
authRes_token
)
(
const
cannedToken
)
result0
let
expected
=
AuthResponse
{
_authRes_valid
=
Just
$
AuthValid
{
_authVal_token
=
cannedToken
,
_authVal_tree_id
=
fromMaybe
(
UnsafeMkNodeId
1
)
$
listToMaybe
$
result0
^..
_Right
.
authRes_valid
.
_Just
.
authVal_tree_id
,
_authVal_user_id
=
fromMaybe
(
UnsafeMkUserId
1
)
$
listToMaybe
$
result0
^..
_Right
.
authRes_valid
.
_Just
.
authVal_user_id
}
,
_authRes_inval
=
Nothing
}
_authRes_token
=
cannedToken
,
_authRes_tree_id
=
fromMaybe
(
UnsafeMkNodeId
1
)
$
listToMaybe
$
result0
^..
_Right
.
authRes_tree_id
,
_authRes_user_id
=
fromMaybe
(
UnsafeMkUserId
1
)
$
listToMaybe
$
result0
^..
_Right
.
authRes_user_id
}
result
`
shouldBe
`
(
Right
expected
)
it
"denies login for user 'alice' if password is invalid"
$
\
((
_testEnv
,
port
),
_
)
->
do
let
authPayload
=
AuthRequest
"alice"
(
GargPassword
"wrong"
)
result
<-
runClientM
(
auth_api
authPayload
)
(
clientEnv
port
)
let
expected
=
AuthResponse
{
_authRes_valid
=
Nothing
,
_authRes_inval
=
Just
$
AuthInvalid
"Invalid username or password"
}
result
`
shouldBe
`
(
Right
expected
)
putText
$
"result: "
<>
show
result
-- result `shouldBe` (Left $ InvalidUsernameOrPassword)
test/Test/API/Errors.hs
View file @
ec271ca6
...
...
@@ -47,7 +47,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
|
Status
{
..
}
<-
simpleStatus
->
liftIO
$
do
statusCode
`
shouldBe
`
404
simpleBody
`
shouldBe
`
[
r
|
{"
error":"Node does not exist (nodeId-99)
"}
|]
simpleBody
`
shouldBe
`
[
r
|
{"
node":99,"error":"Node does not exist
"}
|]
it
"returns the new error if header X-Garg-Error-Scheme: new is passed"
$
\
((
_testEnv
,
port
),
app
)
->
do
withApplication
app
$
do
...
...
test/Test/API/Private.hs
View file @
ec271ca6
...
...
@@ -114,11 +114,7 @@ withValidLogin port ur pwd act = do
result
<-
liftIO
$
runClientM
(
auth_api
authPayload
)
clientEnv
case
result
of
Left
err
->
liftIO
$
throwIO
$
Prelude
.
userError
(
show
err
)
Right
res
|
Just
tkn
<-
_authRes_valid
res
->
act
(
_authVal_token
tkn
)
|
otherwise
->
Prelude
.
fail
$
"No token found in "
<>
show
res
Right
res
->
act
$
_authRes_token
res
tests
::
Spec
...
...
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