Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1473 fixed case creation assignee & tests #1841

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CaseCtrl @Inject() (
.organisations(Permissions.manageCase)
.get(request.organisation)
.orFail(AuthorizationError("Operation not permitted"))
user <- userSrv.current.getOrFail("User")
user <- inputCase.user.fold(userSrv.current.getOrFail("User"))(userSrv.getByName(_).getOrFail("User"))
caseTemplate <- caseTemplateName.map(ct => caseTemplateSrv.get(EntityIdOrName(ct)).visible.richCaseTemplate.getOrFail("CaseTemplate")).flip
richCase <- caseSrv.create(
caseTemplate.fold(inputCase)(inputCase.withCaseTemplate).toCase,
Expand Down
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class CaseCtrl @Inject() (
for {
caseTemplate <- caseTemplateName.map(ct => caseTemplateSrv.get(EntityIdOrName(ct)).visible.richCaseTemplate.getOrFail("CaseTemplate")).flip
organisation <- userSrv.current.organisations(Permissions.manageCase).get(request.organisation).getOrFail("Organisation")
user <- userSrv.current.getOrFail("User")
user <- inputCase.user.fold(userSrv.current.getOrFail("User"))(userSrv.getByName(_).getOrFail("User"))
richCase <- caseSrv.create(
caseTemplate.fold(inputCase)(inputCase.withCaseTemplate).toCase,
Some(user),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class CaseCtrlTest extends PlaySpecification with TestAppBuilder {
"flag":false,
"status":"Waiting"
}
]
],
"user":"[email protected]"
}"""
)
.as[JsObject]
Expand All @@ -140,7 +141,7 @@ class CaseCtrlTest extends PlaySpecification with TestAppBuilder {
pap = 2,
status = "Open",
tags = Set.empty,
owner = Some("certuser@thehive.local"),
owner = Some("certro@thehive.local"),
stats = JsObject.empty
)
)
Expand All @@ -155,7 +156,7 @@ class CaseCtrlTest extends PlaySpecification with TestAppBuilder {
val assignee = app[Database].roTransaction(implicit graph => app[CaseSrv].get(EntityIdOrName(outputCase._id)).assignee.getOrFail("Case"))

assignee must beSuccessfulTry
assignee.get.login shouldEqual "certuser@thehive.local"
assignee.get.login shouldEqual "certro@thehive.local"
}

"try to get a case" in testApp { app =>
Expand Down Expand Up @@ -380,7 +381,7 @@ class CaseCtrlTest extends PlaySpecification with TestAppBuilder {
// Merge result
TestCase(outputCase) must equalTo(
TestCase(
caseId = 26,
caseId = 27,
title = "case#21 / case#22",
description = "description of case #21\n\ndescription of case #22",
severity = 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class CaseCtrlTest extends PlaySpecification with TestAppBuilder {
tags = Set("tag1", "tag2"),
flag = Some(false),
tlp = Some(1),
pap = Some(3)
pap = Some(3),
user = Some("[email protected]")
)
)
)
Expand All @@ -77,7 +78,7 @@ class CaseCtrlTest extends PlaySpecification with TestAppBuilder {
pap = 3,
status = "Open",
summary = None,
user = Some("certuser@thehive.local"),
user = Some("certro@thehive.local"),
customFields = Seq.empty
)

Expand Down