<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright 2017-2026 Adobe.

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

             http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.adobe.testing</groupId>
    <artifactId>s3mock-parent</artifactId>
    <version>5.1.0</version>
  </parent>

  <artifactId>s3mock-integration-tests</artifactId>

  <name>S3Mock - Integration Tests</name>

  <dependencies>
    <dependency>
      <groupId>aws.sdk.kotlin</groupId>
      <artifactId>s3-jvm</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.adobe.testing</groupId>
      <artifactId>s3mock</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <!-- only enforcing build order - all transitive dependencies are removed -->
      <groupId>com.adobe.testing</groupId>
      <artifactId>s3mock-docker</artifactId>
      <type>pom</type>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpmime</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-reflect</artifactId>
      <version>${kotlin.version}</version>
      <scope>test</scope>
    </dependency>
    <!-- Force Kotlin stdlib alignment to match aws-sdk-kotlin 1.5.x requirements -->
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>${kotlin.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-test-junit</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- Force Kotlin coroutines alignment to match aws-sdk-kotlin 1.5.x requirements -->
    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-coroutines-core</artifactId>
      <version>${kotlin-coroutines.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-coroutines-test</artifactId>
      <version>${kotlin-coroutines.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito.kotlin</groupId>
      <artifactId>mockito-kotlin</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>apache-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>aws-crt-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3vectors</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>aws-query-protocol</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>aws-xml-protocol</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3-transfer-manager</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>url-connection-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <!--
        Workaround, AWS SDK for Java v2 currently does not support presigned URLs for POST requests.
        see https://github.com/aws/aws-sdk-java-v2/issues/1493
       -->
      <groupId>tel.schich</groupId>
      <artifactId>aws-s3-post-object-presigner</artifactId>
      <version>0.1.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <configuration combine.self="override">
            <verbose>true</verbose>
            <images>
              <image>
                <alias>s3mock</alias>
                <name>${docker.image.name}</name>
                <run>
                  <log>
                    <enabled>true</enabled>
                  </log>
                  <ports>
                    <port>+docker.host.ip:it.s3mock.port_http:9090</port>
                    <port>+docker.host.ip:it.s3mock.port_https:9191</port>
                    <port>+docker.host.ip:it.s3mock.vectors.port_http:9092</port>
                    <port>+docker.host.ip:it.s3mock.vectors.port_https:9193</port>
                  </ports>
                  <wait>
                    <http>
                      <url>http://${docker.host.ip}:${it.s3mock.port_http}/favicon.ico</url>
                    </http>
                    <time>30000</time>
                  </wait>
                  <env>
                    <COM_ADOBE_TESTING_S3MOCK_STORE_VALID_KMS_KEYS>arn:aws:kms:us-east-1:1234567890:key/valid-test-key-id</COM_ADOBE_TESTING_S3MOCK_STORE_VALID_KMS_KEYS>
                    <COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS>bucket-a, bucket-b</COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS>
                    <COM_ADOBE_TESTING_S3MOCK_STORE_REGION>eu-west-1</COM_ADOBE_TESTING_S3MOCK_STORE_REGION>
                    <SPRING_PROFILES_ACTIVE>vectors</SPRING_PROFILES_ACTIVE>
                  </env>
                  <memory>256000000</memory>
                </run>
              </image>
            </images>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.github.gantsign.maven</groupId>
        <artifactId>ktlint-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!-- There are no unit tests in this module, only integration tests. -->
          <failIfNoTests>false</failIfNoTests>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
        <version>${kotlin.version}</version>
      </plugin>
    </plugins>
    <testSourceDirectory>src/test/kotlin</testSourceDirectory>
  </build>

  <profiles>
    <profile>
      <id>start-docker-for-integration-tests</id>
      <activation>
        <!-- If running with -DskipDocker, this profile won't be active. -->
        <property>
          <name>!skipDocker</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <configuration>
              <!-- Even if this profile is active, we do not start the Docker container if the
               tests are skipped, since it is only used for the integration tests. -->
              <skip>${skipTests}</skip>
            </configuration>
            <executions>
              <execution>
                <id>start-docker-image</id>
                <goals>
                  <goal>start</goal>
                </goals>
                <phase>pre-integration-test</phase>
              </execution>
              <execution>
                <id>stop-docker-image</id>
                <goals>
                  <goal>stop</goal>
                </goals>
                <phase>post-integration-test</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <systemPropertyVariables>
                    <it.s3mock.host>${docker.host.ip}</it.s3mock.host>
                    <it.s3mock.port_https>${it.s3mock.port_https}</it.s3mock.port_https>
                    <it.s3mock.port_http>${it.s3mock.port_http}</it.s3mock.port_http>
                    <it.s3mock.vectors.port_https>${it.s3mock.vectors.port_https}</it.s3mock.vectors.port_https>
                    <it.s3mock.vectors.port_http>${it.s3mock.vectors.port_http}</it.s3mock.vectors.port_http>
                  </systemPropertyVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
