diff --git a/delta/plugins/storage/src/test/resources/storages/database/remote-storage-created.json b/delta/plugins/storage/src/test/resources/storages/database/remote-storage-created.json index d78d4e34d8..1ea2b0e28a 100644 --- a/delta/plugins/storage/src/test/resources/storages/database/remote-storage-created.json +++ b/delta/plugins/storage/src/test/resources/storages/database/remote-storage-created.json @@ -7,7 +7,6 @@ "description": "remoteDescription", "algorithm": "SHA-256", "endpoint" : "http://localhost", - "credentials" : "wqUglodAZzmNk3CEZeZgBA==", "folder" : "myfolder", "readPermission" : "remote/read", "writePermission" : "remote/write", @@ -15,7 +14,6 @@ "@type" : "RemoteDiskStorageValue" }, "source" : { - "credentials" : "wqUglodAZzmNk3CEZeZgBA==", "@type" : "RemoteDiskStorage", "name": "remoteName", "description": "remoteDescription", diff --git a/delta/plugins/storage/src/test/resources/storages/database/remote-storage-updated.json b/delta/plugins/storage/src/test/resources/storages/database/remote-storage-updated.json index 92db6ab655..e819e56a02 100644 --- a/delta/plugins/storage/src/test/resources/storages/database/remote-storage-updated.json +++ b/delta/plugins/storage/src/test/resources/storages/database/remote-storage-updated.json @@ -7,7 +7,6 @@ "description": "remoteDescription", "algorithm": "SHA-256", "endpoint" : "http://localhost", - "credentials" : "wqUglodAZzmNk3CEZeZgBA==", "folder" : "myfolder2", "readPermission" : "remote/read", "writePermission" : "remote/write", @@ -15,7 +14,6 @@ "@type" : "RemoteDiskStorageValue" }, "source" : { - "credentials" : "wqUglodAZzmNk3CEZeZgBA==", "@type" : "RemoteDiskStorage", "name": "remoteName", "description": "remoteDescription", diff --git a/delta/plugins/storage/src/test/resources/storages/database/s3-storage-created.json b/delta/plugins/storage/src/test/resources/storages/database/s3-storage-created.json index 22f84c7c07..403c80e44c 100644 --- a/delta/plugins/storage/src/test/resources/storages/database/s3-storage-created.json +++ b/delta/plugins/storage/src/test/resources/storages/database/s3-storage-created.json @@ -8,8 +8,6 @@ "algorithm" : "SHA-256", "bucket" : "mybucket", "endpoint" : "http://localhost", - "accessKey" : "O2vOp16ah21Fk/B0OucyxQ==", - "secretKey" : "dqO3PR6kLOCFNBk9I6zsZQ==", "readPermission" : "s3/read", "region": "eu-west-1", "writePermission" : "s3/write", @@ -17,8 +15,6 @@ "@type" : "S3StorageValue" }, "source" : { - "secretKey" : "dqO3PR6kLOCFNBk9I6zsZQ==", - "accessKey" : "O2vOp16ah21Fk/B0OucyxQ==", "@type" : "S3Storage", "name": "s3name", "description": "s3description", diff --git a/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json b/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json index fc7701ad1c..2ae1897aa6 100644 --- a/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json +++ b/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json @@ -8,8 +8,6 @@ "algorithm" : "SHA-256", "bucket" : "mybucket2", "endpoint" : "http://localhost", - "accessKey" : "O2vOp16ah21Fk/B0OucyxQ==", - "secretKey" : "dqO3PR6kLOCFNBk9I6zsZQ==", "readPermission" : "s3/read", "region": "eu-west-1", "writePermission" : "s3/write", @@ -17,8 +15,6 @@ "@type" : "S3StorageValue" }, "source" : { - "secretKey" : "dqO3PR6kLOCFNBk9I6zsZQ==", - "accessKey" : "O2vOp16ah21Fk/B0OucyxQ==", "@type" : "S3Storage", "name": "s3name", "description": "s3description", diff --git a/delta/plugins/storage/src/test/resources/storages/remote-storage.json b/delta/plugins/storage/src/test/resources/storages/remote-storage.json index 79fc9b82b2..1dc7d23af4 100644 --- a/delta/plugins/storage/src/test/resources/storages/remote-storage.json +++ b/delta/plugins/storage/src/test/resources/storages/remote-storage.json @@ -7,7 +7,6 @@ "name": "remoteName", "description": "remoteDescription", "endpoint": "http://localhost", - "credentials": "authToken", "folder": "myfolder", "readPermission": "remote/read", "writePermission": "remote/write", diff --git a/delta/plugins/storage/src/test/resources/storages/s3-storage.json b/delta/plugins/storage/src/test/resources/storages/s3-storage.json index cb36da4632..c873bfbb6c 100644 --- a/delta/plugins/storage/src/test/resources/storages/s3-storage.json +++ b/delta/plugins/storage/src/test/resources/storages/s3-storage.json @@ -8,8 +8,6 @@ "description": "s3description", "bucket": "mybucket", "endpoint": "http://localhost", - "accessKey": "accessKey", - "secretKey": "secretKey", "readPermission": "s3/read", "region": "eu-west-1", "writePermission": "s3/write", diff --git a/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-created.json b/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-created.json index 8b8277c938..4c2d63c0fb 100644 --- a/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-created.json +++ b/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-created.json @@ -13,7 +13,6 @@ "@type": "RemoteDiskStorage", "name": "remoteName", "description": "remoteDescription", - "credentials": "wqUglodAZzmNk3CEZeZgBA==", "default": true, "endpoint": "http://localhost", "folder": "myfolder", diff --git a/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-updated.json b/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-updated.json index 127abf86f4..7cc8f2aa38 100644 --- a/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-updated.json +++ b/delta/plugins/storage/src/test/resources/storages/sse/remote-storage-updated.json @@ -13,7 +13,6 @@ "@type": "RemoteDiskStorage", "name": "remoteName", "description": "remoteDescription", - "credentials": "wqUglodAZzmNk3CEZeZgBA==", "default": true, "endpoint": "http://localhost", "folder": "myfolder", diff --git a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json index 711a005f27..350cf75ab8 100644 --- a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json +++ b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json @@ -13,14 +13,12 @@ "@type": "S3Storage", "name": "s3name", "description": "s3description", - "accessKey": "O2vOp16ah21Fk/B0OucyxQ==", "bucket": "mybucket", "default": true, "endpoint": "http://localhost", "maxFileSize": 51, "readPermission": "s3/read", "region": "eu-west-1", - "secretKey": "dqO3PR6kLOCFNBk9I6zsZQ==", "writePermission": "s3/write" }, "_storageId": "https://bluebrain.github.io/nexus/vocabulary/s3-storage", diff --git a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json index dab62cc381..5d0ef9765f 100644 --- a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json +++ b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json @@ -13,14 +13,12 @@ "@type": "S3Storage", "name": "s3name", "description": "s3description", - "accessKey": "O2vOp16ah21Fk/B0OucyxQ==", "bucket": "mybucket", "default": true, "endpoint": "http://localhost", "maxFileSize": 51, "readPermission": "s3/read", "region": "eu-west-1", - "secretKey": "dqO3PR6kLOCFNBk9I6zsZQ==", "writePermission": "s3/write" }, "_storageId": "https://bluebrain.github.io/nexus/vocabulary/s3-storage", diff --git a/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json b/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json index 6b0b13d03c..4658b59fb1 100644 --- a/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json +++ b/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json @@ -13,7 +13,6 @@ "description": "remoteDescription", "algorithm": "SHA-256", "endpoint": "http://localhost", - "credentials": "wqUglodAZzmNk3CEZeZgBA==", "folder": "myfolder", "readPermission": "remote/read", "writePermission": "remote/write", @@ -21,7 +20,6 @@ "@type": "RemoteDiskStorageValue" }, "source": { - "credentials": "wqUglodAZzmNk3CEZeZgBA==", "@type": "RemoteDiskStorage", "name": "remoteName", "description": "remoteDescription", diff --git a/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json b/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json index 06c732b74d..7935114203 100644 --- a/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json +++ b/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json @@ -14,8 +14,6 @@ "algorithm": "SHA-256", "bucket": "mybucket", "endpoint": "http://localhost", - "accessKey": "O2vOp16ah21Fk/B0OucyxQ==", - "secretKey": "dqO3PR6kLOCFNBk9I6zsZQ==", "region": "eu-west-1", "readPermission": "s3/read", "writePermission": "s3/write", @@ -23,8 +21,6 @@ "@type": "S3StorageValue" }, "source": { - "secretKey": "dqO3PR6kLOCFNBk9I6zsZQ==", - "accessKey": "O2vOp16ah21Fk/B0OucyxQ==", "@type": "S3Storage", "name": "s3name", "description": "s3description", diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala index a47d8c8bfa..e95661694d 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala @@ -9,6 +9,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label +import ch.epfl.bluebrain.nexus.testkit.minio.MinioDocker import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import software.amazon.awssdk.regions.Region @@ -27,7 +28,7 @@ trait StorageFixtures extends TestHelpers with CirceLiteral { // format: off implicit val config: StorageTypeConfig = StorageTypeConfig( disk = DiskStorageConfig(diskVolume, Set(diskVolume,tmpVolume), DigestAlgorithm.default, permissions.read, permissions.write, showLocation = false, Some(5000), 50), - amazon = Some(S3StorageConfig(DigestAlgorithm.default, Some("localhost"), Some(Secret("accessKey")), Some(Secret("secretKey")), permissions.read, permissions.write, showLocation = false, 60)), + amazon = Some(S3StorageConfig(DigestAlgorithm.default, Some("localhost"), Some(Secret(MinioDocker.RootUser)), Some(Secret(MinioDocker.RootPassword)), permissions.read, permissions.write, showLocation = false, 60)), remoteDisk = Some(RemoteDiskStorageConfig(DigestAlgorithm.default, BaseUri("http://localhost", Label.unsafe("v1")), None, permissions.read, permissions.write, showLocation = false, 70, RetryStrategyConfig.AlwaysGiveUp)), ) val diskFields = DiskStorageFields(Some("diskName"), Some("diskDescription"), default = true, Some(tmpVolume), Some(Permission.unsafe("disk/read")), Some(Permission.unsafe("disk/write")), Some(1000), Some(50)) diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala index d355101879..3d745713bf 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala @@ -51,21 +51,21 @@ class StorageSerializationSuite extends SerializationSuite with StorageFixtures private val storageEventMetricEncoder = StorageEvent.storageEventMetricEncoder storagesMapping.foreach { case (event, (database, sse), action) => - test(s"Correctly serialize ${event.getClass.getName}") { + test(s"Correctly serialize ${event.getClass.getSimpleName} for ${event.tpe}") { assertEquals(storageEventSerializer.codec(event), database) } - test(s"Correctly deserialize ${event.getClass.getName}") { + test(s"Correctly deserialize ${event.getClass.getSimpleName} for ${event.tpe}") { assertEquals(storageEventSerializer.codec.decodeJson(database), Right(event)) } - test(s"Correctly serialize ${event.getClass.getName} as an SSE") { + test(s"Correctly serialize ${event.getClass.getSimpleName} for ${event.tpe} as an SSE") { storageSseEncoder.toSse .decodeJson(database) .assertRight(SseData(ClassUtils.simpleName(event), Some(projectRef), sse)) } - test(s"Correctly encode ${event.getClass.getName} to metric") { + test(s"Correctly encode ${event.getClass.getSimpleName} for ${event.tpe} to metric") { storageEventMetricEncoder.toMetric.decodeJson(database).assertRight { ProjectScopedMetric( instant, diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala index cfc08bc92b..04076ab32a 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala @@ -12,8 +12,8 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.DigestAlgori import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.Storage.S3Storage import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageValue.S3StorageValue import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.AkkaSourceHelpers -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.FetchFileRejection.{FileNotFound, UnexpectedFetchError} -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.SaveFileRejection.{ResourceAlreadyExists, UnexpectedSaveError} +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.FetchFileRejection.FileNotFound +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.SaveFileRejection.ResourceAlreadyExists import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.MinioSpec._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.permissions.{read, write} import ch.epfl.bluebrain.nexus.delta.sdk.model.Tags @@ -24,13 +24,14 @@ import ch.epfl.bluebrain.nexus.testkit.minio.MinioDocker import ch.epfl.bluebrain.nexus.testkit.minio.MinioDocker._ import io.circe.Json import monix.execution.Scheduler -import org.scalatest.BeforeAndAfterAll +import org.scalatest.{BeforeAndAfterAll, DoNotDiscover} import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpecLike import software.amazon.awssdk.regions.Region import java.util.UUID +@DoNotDiscover class S3StorageSaveAndFetchFileSpec(docker: MinioDocker) extends TestKit(ActorSystem("S3StorageSaveAndFetchFileSpec")) with AnyWordSpecLike @@ -88,11 +89,6 @@ class S3StorageSaveAndFetchFileSpec(docker: MinioDocker) val content = "file content" val entity = HttpEntity(content) - "fail saving a file to a bucket on wrong credentials" in { - val description = FileDescription(uuid, filename, Some(`text/plain(UTF-8)`)) - storage.saveFile.apply(description, entity).rejectedWith[UnexpectedSaveError] - } - "save a file to a bucket" in { val description = FileDescription(uuid, filename, Some(`text/plain(UTF-8)`)) storage.saveFile.apply(description, entity).accepted shouldEqual attributes @@ -103,10 +99,6 @@ class S3StorageSaveAndFetchFileSpec(docker: MinioDocker) consume(sourceFetched) shouldEqual content } - "fail fetching a file to a bucket on wrong credentials" in { - storage.fetchFile.apply(attributes).rejectedWith[UnexpectedFetchError] - } - "fail fetching a file that does not exist" in { storage.fetchFile.apply(attributes.copy(path = Uri.Path("other.txt"))).rejectedWith[FileNotFound] }