Skip to content

Commit

Permalink
Merge branch 'main' into chore/rm-admin-system-testdata-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone authored Apr 22, 2024
2 parents 94ffcb4 + 91a8ff2 commit 630a51d
Show file tree
Hide file tree
Showing 47 changed files with 364 additions and 992 deletions.
1 change: 0 additions & 1 deletion docs/04-publishing-deployment/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ A number of core settings is additionally configurable through system environmen
| app.triplestore.fuseki.repository-name | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_REPOSITORY_NAME | knora-test |
| app.triplestore.fuseki.username | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_USERNAME | admin |
| app.triplestore.fuseki.password | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PASSWORD | test |
| app.cache-service.enabled | KNORA_WEBAPI_CACHE_SERVICE_ENABLED | true |

## Selectively Disabling Routes

Expand Down
6 changes: 4 additions & 2 deletions integration/src/test/scala/org/knora/sipi/SipiIT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentif
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM.ShortcodeIdentifier
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM.ShortnameIdentifier
import org.knora.webapi.messages.util.KnoraSystemInstances.Users.SystemUser
import org.knora.webapi.routing.InvalidTokenCache
import org.knora.webapi.slice.admin.domain.model.KnoraProject
import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri
import org.knora.webapi.slice.admin.domain.service.KnoraProjectRepo
import org.knora.webapi.slice.admin.domain.service.KnoraProjectService
import org.knora.webapi.slice.common.repo.service.CrudRepository
import org.knora.webapi.slice.infrastructure.CacheManager
import org.knora.webapi.slice.infrastructure.JwtService
import org.knora.webapi.slice.infrastructure.JwtServiceLive
import org.knora.webapi.store.cache.CacheService
import org.knora.webapi.testcontainers.SharedVolumes
import org.knora.webapi.testcontainers.SipiTestContainer

Expand Down Expand Up @@ -118,9 +119,10 @@ object SipiIT extends ZIOSpecDefault {
.map(_.jwtString)
.provide(
JwtServiceLive.layer,
InvalidTokenCache.layer,
AppConfig.layer,
CacheManager.layer,
KnoraProjectService.layer,
CacheService.layer,
KnoraProjectRepoInMemory.layer,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import org.knora.webapi.slice.admin.domain.service.ProjectExportStorageService
import org.knora.webapi.slice.admin.domain.service._
import org.knora.webapi.slice.common.api._
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
import org.knora.webapi.slice.infrastructure.CacheManager
import org.knora.webapi.slice.infrastructure.JwtService
import org.knora.webapi.slice.infrastructure.JwtServiceLive
import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints
Expand All @@ -58,9 +59,6 @@ import org.knora.webapi.slice.resourceinfo.ResourceInfoLayers
import org.knora.webapi.slice.resourceinfo.domain.IriConverter
import org.knora.webapi.slice.search.api.SearchApiRoutes
import org.knora.webapi.slice.search.api.SearchEndpoints
import org.knora.webapi.store.cache.CacheService
import org.knora.webapi.store.cache.CacheServiceRequestMessageHandler
import org.knora.webapi.store.cache.CacheServiceRequestMessageHandlerLive
import org.knora.webapi.store.iiif.IIIFRequestMessageHandler
import org.knora.webapi.store.iiif.IIIFRequestMessageHandlerLive
import org.knora.webapi.store.iiif.api.SipiService
Expand Down Expand Up @@ -95,7 +93,7 @@ object LayersTest {
AssetPermissionsResponder &
Authenticator &
AuthorizationRestService &
CacheServiceRequestMessageHandler &
CacheManager &
CardinalityHandler &
ConstructResponseUtilV2 &
DspIngestClient &
Expand All @@ -106,6 +104,7 @@ object LayersTest {
HttpServer &
IIIFRequestMessageHandler &
InferenceOptimizationService &
InvalidTokenCache &
IriConverter &
JwtService &
KnoraUserToUserConverter &
Expand Down Expand Up @@ -155,8 +154,6 @@ object LayersTest {
AuthenticatorLive.layer,
AuthorizationRestService.layer,
BaseEndpoints.layer,
CacheService.layer,
CacheServiceRequestMessageHandlerLive.layer,
CardinalityHandlerLive.layer,
CardinalityService.layer,
ConstructResponseUtilV2Live.layer,
Expand All @@ -168,6 +165,7 @@ object LayersTest {
HttpServer.layer,
IIIFRequestMessageHandlerLive.layer,
InferenceOptimizationService.layer,
InvalidTokenCache.layer,
IriConverter.layer,
IriService.layer,
JwtServiceLive.layer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import org.knora.webapi.messages.IriConversions._
import org.knora.webapi.messages.OntologyConstants
import org.knora.webapi.messages.SmartIri
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.admin.responder.projectsmessages.Project
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM
import org.knora.webapi.messages.store.cacheservicemessages.CacheServiceGetProjectADM
import org.knora.webapi.messages.store.triplestoremessages._
import org.knora.webapi.messages.util.KnoraSystemInstances
import org.knora.webapi.messages.v2.responder.CanDoResponseV2
Expand All @@ -36,8 +33,6 @@ import org.knora.webapi.messages.v2.responder.resourcemessages.CreateValueInNewR
import org.knora.webapi.messages.v2.responder.valuemessages.IntegerValueContentV2
import org.knora.webapi.routing.UnsafeZioRun
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM.imagesProject
import org.knora.webapi.slice.admin.api.service.ProjectRestService
import org.knora.webapi.slice.ontology.domain.model.Cardinality._
import org.knora.webapi.slice.ontology.repo.service.OntologyCache
import org.knora.webapi.store.triplestore.api.TriplestoreService
Expand Down Expand Up @@ -159,28 +154,6 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {
)
}

"invalidate cached project information when adding an ontology to a project" in {
// Ensure that the project is cached
UnsafeZioRun.runOrThrow(ZIO.serviceWithZIO[ProjectRestService](_.findById(imagesProject.projectIri)))

appActor ! CacheServiceGetProjectADM(ProjectIdentifierADM.IriIdentifier.unsafeFrom(imagesProjectIri.toString))
val cachedProjectBefore = expectMsgType[Option[Project]](timeout)
assert(cachedProjectBefore.isDefined)
// create an ontology
appActor ! CreateOntologyRequestV2(
ontologyName = "foo-two",
projectIri = imagesProjectIri,
label = "The foo-two ontology",
apiRequestID = UUID.randomUUID,
requestingUser = imagesUser,
)
expectMsgType[ReadOntologyMetadataV2](timeout)
// ensure that the project is no longer cached
appActor ! CacheServiceGetProjectADM(ProjectIdentifierADM.IriIdentifier.unsafeFrom(imagesProjectIri.toString))
val cachedProject = expectMsgType[Option[Project]](timeout)
assert(cachedProject.isEmpty)
}

"change the label in the metadata of 'foo'" in {
val newLabel = "The modified foo ontology"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.v2.routing.authenticationmessages.CredentialsIdentifier
import org.knora.webapi.messages.v2.routing.authenticationmessages.KnoraCredentialsV2.KnoraJWTTokenCredentialsV2
import org.knora.webapi.messages.v2.routing.authenticationmessages.KnoraCredentialsV2.KnoraPasswordCredentialsV2
import org.knora.webapi.routing.Authenticator.AUTHENTICATION_INVALIDATION_CACHE_NAME
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.Email
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.util.ZioScalaTestUtil.assertFailsWithA
import org.knora.webapi.util.cache.CacheUtil

object AuthenticatorSpec {
private val rootUser = SharedTestDataADM.rootUser
Expand Down Expand Up @@ -74,7 +72,7 @@ class AuthenticatorSpec extends CoreSpec with ImplicitSender with PrivateMethodT
.run(for {
token <- createJwtTokenString(testUserAdmFromIri("http://rdfh.ch/users/X-T8IkfQTKa86UWuISpbOA"))
tokenCreds = KnoraJWTTokenCredentialsV2(token)
_ = CacheUtil.put(AUTHENTICATION_INVALIDATION_CACHE_NAME, tokenCreds.jwtToken, tokenCreds.jwtToken)
_ <- ZIO.serviceWith[InvalidTokenCache](_.put(tokenCreds.jwtToken))
result <- ZIO.serviceWithZIO[Authenticator](_.authenticateCredentialsV2(Some(tokenCreds)))
} yield result)
assertFailsWithA[BadCredentialsException](actual)
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object Dependencies {
val bouncyCastle = "org.bouncycastle" % "bcprov-jdk15to18" % "1.78"

// caching
val ehcache = "net.sf.ehcache" % "ehcache" % "2.10.9.2"
val ehcache = "org.ehcache" % "ehcache" % "3.10.8"

// other
val diff = "com.sksamuel.diff" % "diff" % "1.1.11"
Expand Down
53 changes: 0 additions & 53 deletions webapi/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -364,59 +364,6 @@ app {
project-icons-basepath = "project-icons/"
}

// http://www.ehcache.org/apidocs/2.10/index.html
caches = [
{
cache-name = "ontologyCache"
max-elements-in-memory = 0
overflow-to-disk = false
eternal = true
time-to-live-seconds = 0
time-to-idle-seconds = 0
},
{
cache-name = "userProfileCache"
max-elements-in-memory = 0
overflow-to-disk = false
eternal = true
time-to-live-seconds = 600
time-to-idle-seconds = 0
},
{
cache-name = "userADMCache"
max-elements-in-memory = 0
overflow-to-disk = false
eternal = true
time-to-live-seconds = 600
time-to-idle-seconds = 0
}
{
cache-name = "authenticationInvalidationCache"
max-elements-in-memory = 0
overflow-to-disk = false
eternal = true
time-to-live-seconds = 2592000
time-to-idle-seconds = 0
},
{
cache-name = "mappingCache"
max-elements-in-memory = 0
overflow-to-disk = false
eternal = true
time-to-live-seconds = 600
time-to-idle-seconds = 0
},
{
cache-name = "xsltCache"
max-elements-in-memory = 100
overflow-to-disk = false
eternal = true
time-to-live-seconds = 600
time-to-idle-seconds = 0
}

]

tmp-datadir = "/tmp/webapi_tmp/" // dir must exist on disk!
datadir = "/tmp/webapi/" // dir must exist on disk!

Expand Down
Loading

0 comments on commit 630a51d

Please sign in to comment.