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
157
Issues
157
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
35124c54
Commit
35124c54
authored
Nov 18, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an unpublishing bug in Table.Node.Update
parent
3dc86d39
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
2 deletions
+36
-2
gargantext.cabal
gargantext.cabal
+1
-0
Update.hs
src/Gargantext/Database/Query/Table/Node/Update.hs
+1
-1
Move.hs
test/Test/API/Private/Move.hs
+33
-0
JSON.hs
test/Test/Offline/JSON.hs
+1
-1
No files found.
gargantext.cabal
View file @
35124c54
...
...
@@ -809,6 +809,7 @@ test-suite garg-test-tasty
Test.API.Setup
Test.API.Prelude
Test.API.UpdateList
Test.Core.AsyncUpdates
Test.Core.Notifications
Test.Core.Similarity
Test.Core.Text
...
...
src/Gargantext/Database/Query/Table/Node/Update.hs
View file @
35124c54
...
...
@@ -93,7 +93,7 @@ update loggedInUserId u@(Move sourceId targetId) = do
case
_node_user_id
sourceNode
==
loggedInUserId
of
True
->
do
userPublicFolderNode
<-
getUserRootPublicNode
loggedInUserId
unpublishNode
(
SourceId
$
_node_id
userPublicFolderNode
)
(
TargetId
sourceId
)
unpublishNode
(
SourceId
$
sourceId
)
(
TargetId
$
_node_id
userPublicFolderNode
)
-- Now we can perform the move
update'
u
False
->
nodeError
(
NodeIsReadOnly
targetId
"logged user is not allowed to move/unpublish a read-only node"
)
...
...
test/Test/API/Private/Move.hs
View file @
35124c54
...
...
@@ -80,6 +80,39 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
checkEither
$
runClientM
(
get_tree
token
bobNodeId
)
clientEnv
containsNode
aliceCorpusId
tree
`
shouldBe
`
True
it
"should unpublish Alice's published corpus when moved back to private"
$
\
(
SpecContext
testEnv
serverPort
app
_
)
->
do
withApplication
app
$
do
aliceCorpusId
<-
withValidLogin
serverPort
"alice"
(
GargPassword
"alice"
)
$
\
clientEnv
token
->
do
liftIO
$
do
cId
<-
newCorpusForUser
testEnv
"alice"
alicePublicFolderId
<-
getRootPublicFolderIdForUser
testEnv
(
UserName
"alice"
)
_
<-
checkEither
$
runClientM
(
move_node
token
(
SourceId
cId
)
(
TargetId
alicePublicFolderId
))
clientEnv
-- Check that we can see the folder
aliceNodeId
<-
myUserNodeId
testEnv
"alice"
tree
<-
checkEither
$
runClientM
(
get_tree
token
aliceNodeId
)
clientEnv
assertBool
"alice can't see her own corpus"
(
containsNode
cId
tree
)
pure
cId
withValidLogin
serverPort
"bob"
(
GargPassword
"bob"
)
$
\
clientEnv
token
->
do
tree
<-
liftIO
$
do
bobNodeId
<-
myUserNodeId
testEnv
"bob"
checkEither
$
runClientM
(
get_tree
token
bobNodeId
)
clientEnv
containsNode
aliceCorpusId
tree
`
shouldBe
`
True
-- Now alice moves the node back to her private folder, effectively unpublishing it.
withValidLogin
serverPort
"alice"
(
GargPassword
"alice"
)
$
\
clientEnv
token
->
do
liftIO
$
do
alicePrivateFolderId
<-
getRootPrivateFolderIdForUser
testEnv
(
UserName
"alice"
)
void
$
checkEither
$
runClientM
(
move_node
token
(
SourceId
aliceCorpusId
)
(
TargetId
alicePrivateFolderId
))
clientEnv
withValidLogin
serverPort
"bob"
(
GargPassword
"bob"
)
$
\
clientEnv
token
->
do
tree
<-
liftIO
$
do
bobNodeId
<-
myUserNodeId
testEnv
"bob"
checkEither
$
runClientM
(
get_tree
token
bobNodeId
)
clientEnv
containsNode
aliceCorpusId
tree
`
shouldBe
`
False
it
"shouldn't allow Alice to modify a (strictly) published node even if owner"
$
\
(
SpecContext
testEnv
serverPort
app
_
)
->
do
withApplication
app
$
do
withValidLogin
serverPort
"alice"
(
GargPassword
"alice"
)
$
\
clientEnv
token
->
do
...
...
test/Test/Offline/JSON.hs
View file @
35124c54
...
...
@@ -15,7 +15,6 @@ import Gargantext.API.Node.Types
import
Gargantext.API.Viz.Types
import
Gargantext.Core.Types.Phylo
import
qualified
Gargantext.Core.Viz.Phylo
as
VizPhylo
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
import
Paths_gargantext
import
Prelude
...
...
@@ -32,6 +31,7 @@ jsonRoundtrip a =
class
(
Show
a
,
FromJSON
a
,
ToJSON
a
,
Eq
a
,
Enum
a
,
Bounded
a
)
=>
EnumBoundedJSON
a
instance
EnumBoundedJSON
BackendErrorCode
instance
EnumBoundedJSON
NodeType
instance
EnumBoundedJSON
NodePublishPolicy
jsonEnumRoundtrip
::
forall
a
.
Dict
EnumBoundedJSON
a
->
Property
jsonEnumRoundtrip
d
=
case
d
of
...
...
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