From 53362dec26f26a3836223f8d8fd1367fe2f68e33 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 2 Aug 2023 11:28:42 +0300 Subject: [PATCH] Removed authorizationSource from header + prefix in username --- .github/workflows/test.yml | 3 +- README.adoc | 1 - build.gradle.kts | 1 - .../save/api/SaveBackendFastTest.kt | 10 +----- .../saveourtool/save/api/SaveBackendTest.kt | 10 +----- .../saveourtool/save/api/SaveBackendUtils.kt | 34 ++++++++++++------- 6 files changed, 24 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3da8feb..2014b75 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,9 +49,8 @@ jobs: gradle-version: wrapper arguments: | -Dsave-cloud.backend.url=https://saveourtool.com - -Dsave-cloud.user=github@${{ secrets.SAVE_CLOUD_USER }} + -Dsave-cloud.user=${{ secrets.SAVE_CLOUD_USER }} -Dsave-cloud.password=${{ secrets.SAVE_CLOUD_PASSWORD }} - -Dsave-cloud.user.auth.source=github -Dsave-cloud.project.name=Diktat-Integration -Dsave-cloud.contest.name=Integration-Tests -Dsave-cloud.test.version=save-integration-test diff --git a/README.adoc b/README.adoc index 2e60328..d9884b2 100644 --- a/README.adoc +++ b/README.adoc @@ -15,7 +15,6 @@ The following properties control the behavior of the tests: * `save-cloud.backend.url` * `save-cloud.user` -* `save-cloud.user.auth.source` * `save-cloud.password` * `save-cloud.test.suite.ids` * `save-cloud.test.version` diff --git a/build.gradle.kts b/build.gradle.kts index 4872b70..d00c1de 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -87,7 +87,6 @@ tasks.withType { sequenceOf( "save-cloud.backend.url", "save-cloud.user", - "save-cloud.user.auth.source", "save-cloud.password", "save-cloud.test.suite.ids", "save-cloud.test.version", diff --git a/src/test/kotlin/com/saveourtool/save/api/SaveBackendFastTest.kt b/src/test/kotlin/com/saveourtool/save/api/SaveBackendFastTest.kt index 77f2630..ad67cd7 100644 --- a/src/test/kotlin/com/saveourtool/save/api/SaveBackendFastTest.kt +++ b/src/test/kotlin/com/saveourtool/save/api/SaveBackendFastTest.kt @@ -5,13 +5,11 @@ import com.saveourtool.save.api.assertions.assertNonNull import com.saveourtool.save.api.assertions.fail import com.saveourtool.save.api.errors.SaveCloudError import com.saveourtool.save.testsuite.TestSuiteVersioned -import com.saveourtool.save.utils.AUTHORIZATION_SOURCE import com.saveourtool.save.utils.getLogger import arrow.core.flatMap import arrow.core.getOrElse import io.ktor.client.plugins.auth.providers.BasicAuthCredentials import io.ktor.client.plugins.auth.providers.basic -import io.ktor.client.request.headers import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -35,13 +33,7 @@ class SaveBackendFastTest { requestTimeoutMillis = SECONDS.toMillis(500L) ) { basic { - sendWithoutRequest { requestBuilder -> - requestBuilder.headers { - this[AUTHORIZATION_SOURCE] = authorizationSource - } - - true - } + sendWithoutRequest { true } credentials { BasicAuthCredentials(username = user, password = passwordOrToken) diff --git a/src/test/kotlin/com/saveourtool/save/api/SaveBackendTest.kt b/src/test/kotlin/com/saveourtool/save/api/SaveBackendTest.kt index 8572aa4..98724c7 100644 --- a/src/test/kotlin/com/saveourtool/save/api/SaveBackendTest.kt +++ b/src/test/kotlin/com/saveourtool/save/api/SaveBackendTest.kt @@ -25,12 +25,10 @@ import com.saveourtool.save.execution.TestingType.PRIVATE_TESTS import com.saveourtool.save.execution.TestingType.PUBLIC_TESTS import com.saveourtool.save.request.CreateExecutionRequest import com.saveourtool.save.testsuite.TestSuiteVersioned -import com.saveourtool.save.utils.AUTHORIZATION_SOURCE import com.saveourtool.save.utils.getLogger import arrow.core.getOrElse import io.ktor.client.plugins.auth.providers.BasicAuthCredentials import io.ktor.client.plugins.auth.providers.basic -import io.ktor.client.request.headers import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.api.AfterAll @@ -184,13 +182,7 @@ class SaveBackendTest { requestTimeoutMillis = SECONDS.toMillis(500L) ) { basic { - sendWithoutRequest { requestBuilder -> - requestBuilder.headers { - this[AUTHORIZATION_SOURCE] = authorizationSource - } - - true - } + sendWithoutRequest { true } credentials { BasicAuthCredentials(username = user, password = passwordOrToken) diff --git a/src/test/kotlin/com/saveourtool/save/api/SaveBackendUtils.kt b/src/test/kotlin/com/saveourtool/save/api/SaveBackendUtils.kt index f50e0f8..644ba1f 100644 --- a/src/test/kotlin/com/saveourtool/save/api/SaveBackendUtils.kt +++ b/src/test/kotlin/com/saveourtool/save/api/SaveBackendUtils.kt @@ -8,7 +8,6 @@ package com.saveourtool.save.api import com.saveourtool.save.testsuite.TestSuiteVersioned import org.assertj.core.api.Assumptions.assumeThat -private const val DEFAULT_AUTHORIZATION_SOURCE = "basic" private const val DEFAULT_BACKEND_URL = "http://localhost:5800" private const val DEFAULT_ORGANIZATION_NAME = "saveourtool" private const val DEFAULT_PASSWORD = "" @@ -21,7 +20,7 @@ internal const val TEST_TIMEOUT_MINUTES = 20L @Suppress("CUSTOM_GETTERS_SETTERS") internal val backendUrl: String get() { - val backendUrlOrEmpty = System.getProperty("save-cloud.backend.url", DEFAULT_BACKEND_URL) + val backendUrlOrEmpty = getenvOrProperty("save-cloud.backend.url", DEFAULT_BACKEND_URL) return when { backendUrlOrEmpty.isEmpty() -> DEFAULT_BACKEND_URL @@ -32,7 +31,7 @@ internal val backendUrl: String @Suppress("CUSTOM_GETTERS_SETTERS") internal val user: String get() = - System.getProperty("save-cloud.user", DEFAULT_USER) + getenvOrProperty("save-cloud.user", DEFAULT_USER) /** * @return either the password or the _personal access token_. @@ -40,12 +39,7 @@ internal val user: String @Suppress("CUSTOM_GETTERS_SETTERS") internal val passwordOrToken: String get() = - System.getProperty("save-cloud.password", DEFAULT_PASSWORD) - -@Suppress("CUSTOM_GETTERS_SETTERS") -internal val authorizationSource: String - get() = - System.getProperty("save-cloud.user.auth.source", DEFAULT_AUTHORIZATION_SOURCE) + getenvOrProperty("save-cloud.password", DEFAULT_PASSWORD) @Suppress("CUSTOM_GETTERS_SETTERS") internal val organizationName: String @@ -55,7 +49,7 @@ internal val organizationName: String @Suppress("CUSTOM_GETTERS_SETTERS") internal val projectName: String get() = - System.getProperty("save-cloud.project.name", DEFAULT_PROJECT_NAME) + getenvOrProperty("save-cloud.project.name", DEFAULT_PROJECT_NAME) @Suppress( "NO_CORRESPONDING_PROPERTY", @@ -63,7 +57,7 @@ internal val projectName: String ) internal val testSuiteIds: Set get() { - val rawTestSuiteIds = System.getProperty("save-cloud.test.suite.ids") + val rawTestSuiteIds = getenvOrProperty("save-cloud.test.suite.ids") ?: return emptySet() return rawTestSuiteIds @@ -77,7 +71,7 @@ internal val testSuiteIds: Set @Suppress("CUSTOM_GETTERS_SETTERS") internal val testVersion: String? get() { - val rawTestVersion = System.getProperty("save-cloud.test.version", DEFAULT_TEST_VERSION) + val rawTestVersion = getenvOrProperty("save-cloud.test.version", DEFAULT_TEST_VERSION) return when { rawTestVersion.isEmpty() -> null @@ -89,7 +83,7 @@ internal val testVersion: String? @Suppress("CUSTOM_GETTERS_SETTERS") internal val testLanguage: String? get() { - val rawTestLanguage = System.getProperty("save-cloud.test.language", DEFAULT_TEST_LANGUAGE) + val rawTestLanguage = getenvOrProperty("save-cloud.test.language", DEFAULT_TEST_LANGUAGE) return when { rawTestLanguage.isEmpty() -> null @@ -152,3 +146,17 @@ internal fun List.withinOrganization(): List