Skip to content

Commit

Permalink
Make test work when run via IntelliJ IDEA
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed May 31, 2020
1 parent 601a78a commit 49395c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock.aResponse
import com.github.tomakehurst.wiremock.client.WireMock.anyUrl
import com.github.tomakehurst.wiremock.client.WireMock.containing
import com.github.tomakehurst.wiremock.client.WireMock.equalTo
import com.github.tomakehurst.wiremock.client.WireMock.get
import com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor
import com.github.tomakehurst.wiremock.client.WireMock.matching
import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath
import com.github.tomakehurst.wiremock.client.WireMock.post
import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor
Expand All @@ -33,8 +33,6 @@ import com.github.tomakehurst.wiremock.client.WireMock.urlMatching
import com.github.tomakehurst.wiremock.stubbing.Scenario
import com.google.gson.Gson
import io.github.gradlenexus.publishplugin.internal.StagingRepository
import java.nio.file.Files
import java.nio.file.Path
import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
Expand All @@ -52,6 +50,9 @@ import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.io.TempDir
import ru.lanwen.wiremock.ext.WiremockResolver
import ru.lanwen.wiremock.ext.WiremockResolver.Wiremock
import java.nio.file.Files
import java.nio.file.Path
import java.util.regex.Pattern

@Suppress("FunctionName") // TODO: How to suppress "kotlin:S100" from SonarLint?
@ExtendWith(WiremockResolver::class)
Expand Down Expand Up @@ -697,7 +698,7 @@ class NexusPublishPluginTests {
@SafeVarargs
private fun stubStagingProfileRequest(url: String, vararg stagingProfiles: Map<String, String>) {
server.stubFor(get(urlEqualTo(url))
.withHeader("User-Agent", equalTo("gradle-nexus-publish-plugin/${System.getProperty("plugin.version")}"))
.withHeader("User-Agent", matching("gradle-nexus-publish-plugin/.*"))
.willReturn(aResponse().withBody(gson.toJson(mapOf("data" to listOf(*stagingProfiles))))))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ open class NexusClient(private val baseUrl: URI, username: String?, password: St
}
}
httpClientBuilder.addInterceptor { chain ->
val version = javaClass.`package`.implementationVersion
val version = javaClass.`package`.implementationVersion ?: "dev"
chain.proceed(chain.request().newBuilder()
.header("User-Agent", "gradle-nexus-publish-plugin/$version")
.build())
Expand Down

0 comments on commit 49395c2

Please sign in to comment.