mirror of
https://gitlab.com/mangadex-pub/mangadex_at_home.git
synced 2024-01-19 02:48:37 +00:00
Simplify portions of the code
This commit is contained in:
parent
cf205a707c
commit
87822dd5d3
|
@ -24,6 +24,27 @@ import java.security.PrivateKey
|
||||||
import java.security.spec.InvalidKeySpecException
|
import java.security.spec.InvalidKeySpecException
|
||||||
import java.security.spec.PKCS8EncodedKeySpec
|
import java.security.spec.PKCS8EncodedKeySpec
|
||||||
|
|
||||||
|
// The code below is adapted from from https://github.com/Mastercard/client-encryption-java/blob/master/src/main/java/com/mastercard/developer/utils/EncryptionUtils.java
|
||||||
|
//
|
||||||
|
// Copyright (c) 2019 Mastercard
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
private const val PKCS_1_PEM_HEADER = "-----BEGIN RSA PRIVATE KEY-----"
|
private const val PKCS_1_PEM_HEADER = "-----BEGIN RSA PRIVATE KEY-----"
|
||||||
private const val PKCS_1_PEM_FOOTER = "-----END RSA PRIVATE KEY-----"
|
private const val PKCS_1_PEM_FOOTER = "-----END RSA PRIVATE KEY-----"
|
||||||
private const val PKCS_8_PEM_HEADER = "-----BEGIN PRIVATE KEY-----"
|
private const val PKCS_8_PEM_HEADER = "-----BEGIN PRIVATE KEY-----"
|
||||||
|
|
|
@ -78,7 +78,6 @@ private val JACKSON: ObjectMapper = jacksonObjectMapper()
|
||||||
|
|
||||||
class ImageServer(
|
class ImageServer(
|
||||||
private val storage: ImageStorage,
|
private val storage: ImageStorage,
|
||||||
private val statistics: AtomicReference<Statistics>,
|
|
||||||
private val client: HttpHandler,
|
private val client: HttpHandler,
|
||||||
registry: PrometheusMeterRegistry
|
registry: PrometheusMeterRegistry
|
||||||
) {
|
) {
|
||||||
|
@ -268,7 +267,6 @@ fun getServer(
|
||||||
|
|
||||||
val imageServer = ImageServer(
|
val imageServer = ImageServer(
|
||||||
storage = storage,
|
storage = storage,
|
||||||
statistics = statistics,
|
|
||||||
client = client,
|
client = client,
|
||||||
registry = registry
|
registry = registry
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,6 @@ import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import mdnet.cache.ImageStorage
|
import mdnet.cache.ImageStorage
|
||||||
import mdnet.data.Statistics
|
|
||||||
import mdnet.security.TweetNaclFast
|
import mdnet.security.TweetNaclFast
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.http4k.core.HttpHandler
|
import org.http4k.core.HttpHandler
|
||||||
|
@ -48,7 +47,6 @@ import org.http4k.routing.bind
|
||||||
import org.http4k.routing.routes
|
import org.http4k.routing.routes
|
||||||
import org.ktorm.database.Database
|
import org.ktorm.database.Database
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
|
||||||
|
|
||||||
class ImageServerTest : FreeSpec() {
|
class ImageServerTest : FreeSpec() {
|
||||||
override fun isolationMode() = IsolationMode.InstancePerTest
|
override fun isolationMode() = IsolationMode.InstancePerTest
|
||||||
|
@ -76,7 +74,6 @@ class ImageServerTest : FreeSpec() {
|
||||||
|
|
||||||
val server = ImageServer(
|
val server = ImageServer(
|
||||||
storage,
|
storage,
|
||||||
AtomicReference(Statistics()),
|
|
||||||
client,
|
client,
|
||||||
registry
|
registry
|
||||||
)
|
)
|
||||||
|
@ -125,7 +122,6 @@ class ImageServerTest : FreeSpec() {
|
||||||
|
|
||||||
val server = ImageServer(
|
val server = ImageServer(
|
||||||
storage,
|
storage,
|
||||||
AtomicReference(Statistics()),
|
|
||||||
client,
|
client,
|
||||||
registry
|
registry
|
||||||
)
|
)
|
||||||
|
@ -174,7 +170,6 @@ class ImageServerTest : FreeSpec() {
|
||||||
|
|
||||||
val server = ImageServer(
|
val server = ImageServer(
|
||||||
storage,
|
storage,
|
||||||
AtomicReference(Statistics()),
|
|
||||||
client,
|
client,
|
||||||
registry
|
registry
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue