diff --git a/build.gradle b/build.gradle index ed0ecbb..fd4d7b9 100644 --- a/build.gradle +++ b/build.gradle @@ -35,11 +35,6 @@ java { } } -jar { - duplicatesStrategy(DuplicatesStrategy.EXCLUDE) -} - - test { // set properties for the tests def propertiesForTests = ["testdockerwithoutsudo"] @@ -82,8 +77,6 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version_no") implementation("com.hierynomus:sshj:0.38.0") - implementation("aws.sdk.kotlin:s3:1.2.54") - testFixturesApi('io.mockk:mockk:1.12.3') testFixturesApi("org.junit.jupiter:junit-jupiter-api:5.8.2") diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/syspec/infrastructure/Verification.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/syspec/infrastructure/Verification.kt index d4a5282..bee923e 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/syspec/infrastructure/Verification.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/syspec/infrastructure/Verification.kt @@ -1,10 +1,5 @@ package org.domaindrivenarchitecture.provs.syspec.infrastructure -import aws.sdk.kotlin.services.s3.S3Client -import aws.sdk.kotlin.services.s3.model.ListObjectsRequest -import aws.sdk.kotlin.services.s3.model.ListObjectsResponse -import aws.smithy.kotlin.runtime.time.Instant -import kotlinx.coroutines.runBlocking import org.domaindrivenarchitecture.provs.framework.core.Prov import org.domaindrivenarchitecture.provs.framework.core.ProvResult import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkDir @@ -13,7 +8,6 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.isPackag import org.domaindrivenarchitecture.provs.syspec.domain.* import java.text.ParseException import java.text.SimpleDateFormat -import java.time.Duration import java.util.* import java.util.concurrent.TimeUnit @@ -29,7 +23,6 @@ fun Prov.verifySpecConfig(conf: SyspecConfig) = task { conf.netcat?.let { task("NetcatSpecs") { for (spec in conf.netcat) verify(spec) } } conf.socket?.let { task("SocketSpecs") { for (spec in conf.socket) verify(spec) } } conf.certificate?.let { task("CertificateFileSpecs") { for (spec in conf.certificate) verify(spec) } } - conf.s3?.let { task("CertificateFileSpecs") { for (spec in conf.s3) verify(spec) } } } // ------------------------------- verification functions for individual specs -------------------------------- @@ -112,27 +105,6 @@ fun Prov.verify(cert: CertificateFileSpec) { } } -fun Prov.verify(s3ObjectSpec: S3ObjectSpec) { - val (bucket, prefix, maxAge) = s3ObjectSpec - val expectedAge = Duration.ofHours(s3ObjectSpec.age) - - val latestObject = getS3Objects(bucket, prefix).contents?.maxByOrNull { it.lastModified ?: Instant.fromEpochSeconds(0) } - - if (latestObject == null) { - verify(false, "Could not retrieve an s3 object with prefix $prefix") - } else { - // convert to java.time.Instant for easier comparison - val lastModified = java.time.Instant.ofEpochSecond(latestObject.lastModified?.epochSeconds ?: 0) - val actualAge = Duration.between(lastModified, java.time.Instant.now()) - - verify( - actualAge <= expectedAge, - "Age is ${actualAge.toHours()} h (expected: <= $maxAge) for latest file with prefix \"$prefix\" " + - "--- modified date: $lastModified - size: ${(latestObject.size)} B - key: ${latestObject.key}" - ) - } -} - // -------------------------- helper functions --------------------------------- @@ -215,14 +187,3 @@ private fun Prov.verifyCertExpiration(enddate: String?, certName: String, expira ) } } - -private fun getS3Objects(bucketName: String, prefixIn: String): ListObjectsResponse { - - val request = ListObjectsRequest { bucket = bucketName; prefix = prefixIn } - - return runBlocking { - S3Client { region = "eu-central-1" }.use { s3 -> - s3.listObjects(request) - } - } -}