Skip to content
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 @@ -6,6 +6,6 @@ object Constants {

const val PLATFORM_ADMIN_EMAIL = "[email protected]"
const val ORGANIZATION_USER_EMAIL = "[email protected]"
const val DEFAULT_ISSUER = "test-issuer"
const val DEFAULT_SUBJECT = "test-subject"
const val PLATFORM_ADMIN_API_KEY_VALUE = "PlatformAdminApiTestKeyValue"
const val ORGANIZATION_USER_API_KEY_VALUE = "OrganizationUserApiTestKeyValue"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Licensed under the MIT license.
package com.cosmotech.api.home

import com.cosmotech.api.home.Constants.ORGANIZATION_USER_EMAIL
import com.cosmotech.api.home.Constants.PLATFORM_ADMIN_EMAIL
import com.cosmotech.dataset.domain.Dataset
import com.cosmotech.dataset.domain.DatasetPart
import com.cosmotech.organization.domain.Organization
Expand Down Expand Up @@ -86,7 +88,10 @@ abstract class ControllerTestBase : AbstractTestcontainersRedisTestBase() {
documentationConfiguration(restDocumentationContextProvider)
.operationPreprocessors()
.withRequestDefaults(
modifyHeaders().remove(HttpHeaders.CONTENT_LENGTH), prettyPrint())
modifyHeaders().remove(HttpHeaders.CONTENT_LENGTH),
modifyHeaders().remove(PLATFORM_ADMIN_EMAIL),
modifyHeaders().remove(ORGANIZATION_USER_EMAIL),
prettyPrint())
.withResponseDefaults(
modifyHeaders()
.remove("X-Content-Type-Options")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Licensed under the MIT license.
package com.cosmotech.api.home

import com.cosmotech.api.home.Constants.ORGANIZATION_USER_API_KEY_VALUE
import com.cosmotech.api.home.Constants.ORGANIZATION_USER_EMAIL
import com.cosmotech.api.home.Constants.PLATFORM_ADMIN_API_KEY_VALUE
import com.cosmotech.api.home.Constants.PLATFORM_ADMIN_EMAIL
import com.cosmotech.api.home.dataset.DatasetConstants.DATASET_DESCRIPTION
import com.cosmotech.api.home.dataset.DatasetConstants.DATASET_NAME
import com.cosmotech.api.home.dataset.DatasetConstants.DATASET_PART_DESCRIPTION
Expand Down Expand Up @@ -31,6 +35,7 @@ import org.springframework.http.MediaType
import org.springframework.mock.web.MockMultipartFile
import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
Expand All @@ -46,6 +51,7 @@ class ControllerTestUtils {
JSONObject(
mvc.perform(
post("/organizations")
.withPlatformAdminHeader()
.contentType(MediaType.APPLICATION_JSON)
.content(JSONObject(organizationCreateRequest).toString())
.accept(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -75,6 +81,7 @@ class ControllerTestUtils {
JSONObject(
mvc.perform(
post("/organizations/$organizationId/solutions")
.withPlatformAdminHeader()
.contentType(MediaType.APPLICATION_JSON)
.content(JSONObject(solutionCreateRequest).toString())
.accept(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -150,6 +157,7 @@ class ControllerTestUtils {
JSONObject(
mvc.perform(
post("/organizations/$organizationId/workspaces/$workspaceId/runners")
.withPlatformAdminHeader()
.contentType(MediaType.APPLICATION_JSON)
.content(JSONObject(runnerCreateRequest).toString())
.accept(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -233,6 +241,7 @@ class ControllerTestUtils {
JSONObject(
mvc.perform(
post("/organizations/$organizationId/workspaces")
.withPlatformAdminHeader()
.contentType(MediaType.APPLICATION_JSON)
.content(
JSONObject(
Expand All @@ -257,6 +266,7 @@ class ControllerTestUtils {
JSONObject(
mvc.perform(
post("/organizations/$organizationId/workspaces")
.withPlatformAdminHeader()
.contentType(MediaType.APPLICATION_JSON)
.content(JSONObject(workspaceCreateRequest).toString())
.accept(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -356,6 +366,7 @@ class ControllerTestUtils {
multipart("/organizations/$organizationId/workspaces/$workspaceId/datasets")
.file(datasetCreateRequestFile)
.file(files)
.withPlatformAdminHeader()
.accept(MediaType.APPLICATION_JSON)
.with(csrf()))
.andReturn()
Expand All @@ -376,6 +387,7 @@ class ControllerTestUtils {
mvc.perform(
get(
"/organizations/$organizationId/workspaces/$workspaceId/datasets/$datasetId")
.withPlatformAdminHeader()
.accept(MediaType.APPLICATION_JSON)
.with(csrf()))
.andReturn()
Expand Down Expand Up @@ -418,6 +430,7 @@ class ControllerTestUtils {
"/organizations/$organizationId/workspaces/$workspaceId/datasets/$datasetId/parts")
.file(datasetPartCreateRequestFile)
.file(file)
.withPlatformAdminHeader()
.accept(MediaType.APPLICATION_JSON)
.with(csrf()))
.andReturn()
Expand Down Expand Up @@ -464,3 +477,9 @@ class ControllerTestUtils {
}
}
}

fun MockHttpServletRequestBuilder.withPlatformAdminHeader(): MockHttpServletRequestBuilder =
this.header(PLATFORM_ADMIN_EMAIL, PLATFORM_ADMIN_API_KEY_VALUE)

fun MockHttpServletRequestBuilder.withOrganizationUserHeader(): MockHttpServletRequestBuilder =
this.header(ORGANIZATION_USER_EMAIL, ORGANIZATION_USER_API_KEY_VALUE)

This file was deleted.

Loading
Loading