-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
73 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,14 +57,18 @@ class ConfigCtrlTest extends PlaySpecification with TestAppBuilder { | |
import app.thehiveModuleV0._ | ||
|
||
tagSrv.freeTagColour | ||
val request = FakeRequest("PUT", "/api/config/tags.freeTagColour") | ||
val setRequest = FakeRequest("PUT", "/api/config/tags.freeTagColour") | ||
.withHeaders("user" -> "[email protected]") | ||
.withJsonBody(Json.parse("""{"value": "#00FF00"}""")) | ||
val result = configCtrl.set("tags.freeTagColour")(request) | ||
val result = configCtrl.set("tags.freeTagColour")(setRequest) | ||
|
||
status(result) must equalTo(204).updateMessage(s => s"$s\n${contentAsString(result)}") | ||
|
||
tagSrv.freeTagColour must beEqualTo("#00FF00") | ||
val getRequest = FakeRequest("GET", "/config/tags.freeTagColour") | ||
.withHeaders("user" -> "[email protected]") | ||
(contentAsJson(configCtrl.get("tags.freeTagColour")(getRequest)) \ "value").as[String] must beEqualTo("#00FF00") | ||
|
||
// tagSrv.freeTagColour must beEqualTo("#00FF00") | ||
|
||
} | ||
// TODO leave unused tests ? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ import org.thp.thehive.models.Profile | |
import org.thp.thehive.services.TheHiveOps | ||
import play.api.libs.json.Json | ||
import play.api.test.{FakeRequest, PlaySpecification} | ||
import eu.timepit.refined.auto._ | ||
import org.thp.thehive.dto.String64 | ||
|
||
class ShareCtrlTest extends PlaySpecification with TestAppBuilder { | ||
"share a case" in testApp { app => | ||
|
@@ -18,7 +20,11 @@ class ShareCtrlTest extends PlaySpecification with TestAppBuilder { | |
import ops._ | ||
|
||
val request = FakeRequest("POST", "/api/case/1/shares") | ||
.withJsonBody(Json.obj("shares" -> List(Json.toJson(InputShare("soc", Profile.orgAdmin.name, TasksFilter.all, ObservablesFilter.all))))) | ||
.withJsonBody( | ||
Json.obj( | ||
"shares" -> List(Json.toJson(InputShare("soc", String64("profileName", Profile.orgAdmin.name), TasksFilter.all, ObservablesFilter.all))) | ||
) | ||
) | ||
.withHeaders("user" -> "[email protected]") | ||
val result = shareCtrl.shareCase("1")(request) | ||
|
||
|
@@ -34,7 +40,11 @@ class ShareCtrlTest extends PlaySpecification with TestAppBuilder { | |
import app.thehiveModuleV0._ | ||
|
||
val request = FakeRequest("POST", "/api/case/2/shares") | ||
.withJsonBody(Json.obj("shares" -> Seq(Json.toJson(InputShare("soc", Profile.orgAdmin.name, TasksFilter.all, ObservablesFilter.all))))) | ||
.withJsonBody( | ||
Json.obj( | ||
"shares" -> Seq(Json.toJson(InputShare("soc", String64("profileName", Profile.orgAdmin.name), TasksFilter.all, ObservablesFilter.all))) | ||
) | ||
) | ||
.withHeaders("user" -> "[email protected]") | ||
val result = shareCtrl.shareCase("2")(request) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package org.thp.thehive.controllers.v1 | ||
|
||
import eu.timepit.refined.auto._ | ||
import io.scalaland.chimney.dsl.TransformerOps | ||
import org.thp.scalligraph.controllers.FakeTemporaryFile | ||
import org.thp.thehive.dto.String128 | ||
import org.thp.thehive.dto.v1._ | ||
import play.api.libs.Files | ||
import play.api.libs.json.{JsArray, Json} | ||
import play.api.libs.json.{JsArray, JsString, Json} | ||
import play.api.mvc.MultipartFormData.FilePart | ||
import play.api.mvc.{AnyContentAsMultipartFormData, MultipartFormData} | ||
import play.api.test.{FakeRequest, PlaySpecification} | ||
|
@@ -102,15 +104,15 @@ class TaxonomyCtrlTest extends PlaySpecification with TestAppBuilder { | |
"return error if namespace is empty" in testApp { app => | ||
import app.thehiveModuleV1._ | ||
|
||
val emptyNamespace = inputTaxo.copy(namespace = "") | ||
// val emptyNamespace = inputTaxo.copy(namespace = String128("namespace", "")) | ||
|
||
val request = FakeRequest("POST", "/api/v1/taxonomy") | ||
.withJsonBody(Json.toJson(emptyNamespace)) | ||
.withJsonBody(Json.toJsObject(inputTaxo) + ("namespace" -> JsString(""))) | ||
.withHeaders("user" -> "[email protected]") | ||
|
||
val result = taxonomyCtrl.create(request) | ||
status(result) must beEqualTo(400).updateMessage(s => s"$s\n${contentAsString(result)}") | ||
(contentAsJson(result) \ "type").as[String] must beEqualTo("BadRequest") | ||
(contentAsJson(result) \ "type").as[String] must beEqualTo("AttributeCheckingError") | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import play.api.libs.json.JsString | |
import play.api.test.PlaySpecification | ||
|
||
import java.util.Date | ||
import eu.timepit.refined.auto._ | ||
|
||
class AlertSrvTest extends PlaySpecification with TestAppBuilder with TheHiveOpsNoDeps { | ||
implicit val authContext: AuthContext = DummyUserSrv(userId = "[email protected]", organisation = "cert").authContext | ||
|