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

chore: Remove test data generation for system and admin (groups, project, users) (DEV-3523) #3203

Merged
merged 4 commits into from
Apr 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,14 @@ class HealthRouteE2ESpec extends E2ESpec {
FiniteDuration(appConfig.defaultTimeout.toNanos, NANOSECONDS),
)

// Directory path for generated client test data
private val clientTestDataPath: Seq[String] = Seq("system", "health")

// Collects client test data
private val clientTestDataCollector = new ClientTestDataCollector(appConfig)

"The Health Route" should {

"return 'OK' for state 'Running'" in {

val request = Get(baseApiUrl + s"/health")
val response: HttpResponse = singleAwaitingRequest(request)
val responseStr: String = responseToString(response)
val responseHeadersStr: String = response.headers.map(_.toString).mkString("\n")
val request = Get(baseApiUrl + s"/health")
val response: HttpResponse = singleAwaitingRequest(request)

response.status should be(StatusCodes.OK)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "running-response",
fileExtension = "json",
),
text = responseStr,
),
)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "response-headers",
fileExtension = "json",
),
text = responseHeadersStr,
),
)
}

"return 'ServiceUnavailable' for state 'Stopped'" in {
Expand All @@ -82,20 +52,8 @@ class HealthRouteE2ESpec extends E2ESpec {

val request = Get(baseApiUrl + s"/health")
val response: HttpResponse = singleAwaitingRequest(request)
val responseStr: String = responseToString(response)

response.status should be(StatusCodes.ServiceUnavailable)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "stopped-response",
fileExtension = "json",
),
text = responseStr,
),
)
}

"return 'ServiceUnavailable' for state 'MaintenanceMode'" in {
Expand All @@ -112,21 +70,7 @@ class HealthRouteE2ESpec extends E2ESpec {

val request = Get(baseApiUrl + s"/health")
val response: HttpResponse = singleAwaitingRequest(request)
val responseStr: String = responseToString(response)

response.status should be(StatusCodes.ServiceUnavailable)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "maintenance-mode-response",
fileExtension = "json",
),
text = responseStr,
),
)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import scala.concurrent.Await
import scala.concurrent.duration._

import org.knora.webapi.E2ESpec
import org.knora.webapi.e2e.ClientTestDataCollector
import org.knora.webapi.e2e.TestDataFileContent
import org.knora.webapi.e2e.TestDataFilePath
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupsADMJsonProtocol
import org.knora.webapi.messages.store.triplestoremessages.StringLiteralV2
import org.knora.webapi.sharedtestdata.SharedTestDataADM
Expand All @@ -32,11 +29,6 @@ import pekko.http.scaladsl.unmarshalling.Unmarshal
class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {

implicit def default: RouteTestTimeout = RouteTestTimeout(30.seconds)
// Directory path for generated client test data
private val clientTestDataPath: Seq[String] = Seq("admin", "groups")

// Collects client test data
private val clientTestDataCollector = new ClientTestDataCollector(appConfig)

private val imagesUser01Email = SharedTestDataADM.imagesUser01.email
private val testPass = SharedTestDataADM.testPass
Expand All @@ -51,16 +43,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
Get(baseApiUrl + s"/admin/groups") ~> addCredentials(BasicHttpCredentials(imagesUser01Email, testPass))
val response: HttpResponse = singleAwaitingRequest(request)
assert(response.status === StatusCodes.OK)
clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "get-groups-response",
fileExtension = "json",
),
text = responseToString(response),
),
)
}

"return the group's information" in {
Expand All @@ -69,16 +51,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
)
val response: HttpResponse = singleAwaitingRequest(request)
assert(response.status === StatusCodes.OK)
clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "get-group-response",
fileExtension = "json",
),
text = responseToString(response),
),
)
}
}

Expand All @@ -94,17 +66,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
| "selfjoin": false
|}""".stripMargin

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "create-group-with-custom-Iri-request",
fileExtension = "json",
),
text = createGroupWithCustomIriRequest,
),
)

val request = Post(
baseApiUrl + s"/admin/groups",
HttpEntity(ContentTypes.`application/json`, createGroupWithCustomIriRequest),
Expand All @@ -117,16 +78,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {

// check that the custom IRI is correctly assigned
result.id should be(customGroupIri)
clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "create-group-with-custom-Iri-response",
fileExtension = "json",
),
text = responseToString(response),
),
)
}

"return 'BadRequest' if the supplied IRI for the group is not unique" in {
Expand Down Expand Up @@ -165,17 +116,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
| "selfjoin": false
|}""".stripMargin

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "create-group-request",
fileExtension = "json",
),
text = createGroupRequest,
),
)

val request = Post(
baseApiUrl + "/admin/groups",
HttpEntity(ContentTypes.`application/json`, createGroupRequest),
Expand All @@ -190,20 +130,7 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
group.project should be(Some(SharedTestDataADM.imagesProjectExternal))
group.status should be(true)
group.selfjoin should be(false)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "create-group-response",
fileExtension = "json",
),
text = responseToString(response),
),
)

val iri = group.id
newGroupIri.set(iri)
newGroupIri.set(group.id)
}

"UPDATE a group" in {
Expand All @@ -212,17 +139,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
| "name": "UpdatedGroupName",
| "descriptions": [{"value": "UpdatedGroupDescription", "language": "en"}]
|}""".stripMargin

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "update-group-request",
fileExtension = "json",
),
text = updateGroupRequest,
),
)
val groupIriEnc = java.net.URLEncoder.encode(newGroupIri.get, "utf-8")
val request = Put(
baseApiUrl + "/admin/groups/" + groupIriEnc,
Expand All @@ -238,17 +154,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
groupInfo.project should be(Some(SharedTestDataADM.imagesProjectExternal))
groupInfo.status should be(true)
groupInfo.selfjoin should be(false)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "update-group-response",
fileExtension = "json",
),
text = responseToString(response),
),
)
}

"DELETE a group" in {
Expand All @@ -266,18 +171,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
groupInfo.project should be(Some(SharedTestDataADM.imagesProjectExternal))
groupInfo.status should be(false)
groupInfo.selfjoin should be(false)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "delete-group-response",
fileExtension = "json",
),
text = responseToString(response),
),
)

}

"CHANGE status of a group" in {
Expand All @@ -286,17 +179,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
| "status": true
|}""".stripMargin

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "change-group-status-request",
fileExtension = "json",
),
text = changeGroupStatusRequest,
),
)

val groupIriEnc = java.net.URLEncoder.encode(newGroupIri.get, "utf-8")
val request = Put(
baseApiUrl + "/admin/groups/" + groupIriEnc + "/status",
Expand All @@ -312,17 +194,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
groupInfo.project should be(Some(SharedTestDataADM.imagesProjectExternal))
groupInfo.status should be(true)
groupInfo.selfjoin should be(false)

clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "change-group-status-response",
fileExtension = "json",
),
text = responseToString(response),
),
)
}
}

Expand All @@ -333,16 +204,6 @@ class GroupsADME2ESpec extends E2ESpec with GroupsADMJsonProtocol {
)
val response: HttpResponse = singleAwaitingRequest(request)
assert(response.status === StatusCodes.OK, responseToString(response))
clientTestDataCollector.addFile(
TestDataFileContent(
filePath = TestDataFilePath(
directoryPath = clientTestDataPath,
filename = "get-group-members-response",
fileExtension = "json",
),
text = responseToString(response),
),
)
}
}
}
Expand Down
Loading
Loading