Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gradle
.intellijPlatform
.kotlin
out/
target/
.idea
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ dependencies {
testImplementation(libs.junit4)
testImplementation(libs.bundles.mockito)
testImplementation(gradleTestKit())

testRuntimeOnly(libs.junit5.jupiterVintage)
}

tasks.test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ tasks.verifyPlugin {
// give each instance its own home dir
systemProperty("plugin.verifier.home.dir", temporaryDir)
}

val pluginZip by configurations.creating
artifacts {
add("pluginZip", tasks.buildPlugin)
}
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/toolkit-testing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ dependencies {

// Everything uses junit4/5 except rider, which uses TestNG
testFixturesApi(platform(versionCatalog.findLibrary("junit5-bom").get()))
testFixturesApi(versionCatalog.findLibrary("junit5-jupiterApi").get())
testFixturesApi(versionCatalog.findLibrary("junit5-jupiterParams").get())
testFixturesApi(versionCatalog.findLibrary("junit5-jupiter").get())

testRuntimeOnly(versionCatalog.findLibrary("junit5-jupiterEngine").get())
testRuntimeOnly(versionCatalog.findLibrary("junit-platform-launcher").get())
testRuntimeOnly(versionCatalog.findLibrary("junit5-jupiterVintage").get())
}

Expand Down
5 changes: 2 additions & 3 deletions buildspec/linuxUiTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
phases:
install:
commands:
- dnf install -y marco mate-media
- dnf install -y marco mate-media e2fsprogs
- startDesktop.sh

# login to DockerHub so we don't get throttled
Expand All @@ -45,10 +45,9 @@ phases:
credential_source=EcsContainer"

- chmod +x gradlew
- ./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME :sandbox-all:prepareTestIdeUiSandbox --console plain --info

- ffmpeg -loglevel quiet -nostdin -f x11grab -video_size ${SCREEN_WIDTH}x${SCREEN_HEIGHT} -i ${DISPLAY} -codec:v libx264 -pix_fmt yuv420p -vf drawtext="fontsize=48:box=1:[email protected]:boxborderw=5:fontcolor=white:x=0:y=h-text_h:text='%{gmtime\:%H\\\\\:%M\\\\\:%S}'" -framerate 12 -g 12 /tmp/screen_recording.mp4 &
- ./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME uiTestCore coverageReport --console plain --info
- ./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME :ui-tests-starter:test coverageReport --console plain --info

post_build:
commands:
Expand Down
1 change: 0 additions & 1 deletion detekt-rules/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies {

// only used to make test work
testRuntimeOnly(libs.slf4j.api)
testRuntimeOnly(libs.junit5.jupiterVintage)
}

tasks.test {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ toolkitVersion=3.45-SNAPSHOT
publishToken=
publishChannel=

ideProfileName=2024.1
ideProfileName=2024.2

remoteRobotPort=8080

Expand Down
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ jackson-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xm
jackson-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" }
jacoco = { module = "org.jacoco:org.jacoco.core", version.ref = "jacoco" }
jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "jgit" }

# platfom launcher version selected by BOM
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }

junit4 = { module = "junit:junit", version.ref = "junit4" }
junit5-bom = { module = "org.junit:junit-bom", version.ref = "junit5" }
junit5-jupiterApi = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
junit5-jupiterEngine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }
junit5-jupiterParams = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit5" }
junit5-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit5" }
junit5-jupiterVintage = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit5" }
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinCoroutines" }
kotlin-coroutinesDebug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "kotlinCoroutines" }
Expand Down
5 changes: 5 additions & 0 deletions noop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

// project that does nothing
tasks.register("test")
1 change: 0 additions & 1 deletion plugins/core/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies {
implementation(libs.commonmark)
testImplementation(libs.junit4)

testRuntimeOnly(libs.junit5.jupiterVintage)
testRuntimeOnly(project(":plugin-core:resources"))
testRuntimeOnly(project(":plugin-core:sdk-codegen"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
*/
fun currentToken(): AccessToken?

/**
* Not meant to be invoked outside the implementation
*/
fun refresh(): AccessToken

/**
Expand All @@ -58,13 +61,13 @@
/**
* Request provider to interactively request user input to obtain a new [AccessToken]
*/
open fun reauthenticate() {
fun reauthenticate() {
throw UnsupportedOperationException("Provider is not interactive and cannot reauthenticate")
}

open fun supportsLogout() = this is BearerTokenLogoutSupport
fun supportsLogout() = this is BearerTokenLogoutSupport

Check warning on line 68 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/bearer/BearerTokenProvider.kt

View check run for this annotation

Codecov / codecov/patch

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/bearer/BearerTokenProvider.kt#L68

Added line #L68 was not covered by tests

open fun invalidate() {
fun invalidate() {
throw UnsupportedOperationException("Provider is not interactive and cannot be invalidated")
}

Expand All @@ -90,10 +93,9 @@
val startUrl: String,
val region: String,
val scopes: List<String>,
id: String,
override val id: String,
cache: DiskCache = diskCache,
) : BearerTokenProvider, BearerTokenLogoutSupport, Disposable {
override val id = id
override val displayName = ToolkitBearerTokenProvider.ssoDisplayName(startUrl)

private val ssoOidcClient: SsoOidcClient = buildUnmanagedSsoOidcClient(region)
Expand All @@ -107,7 +109,7 @@
)

private val supplier = CachedSupplier.builder { refreshToken() }.prefetchStrategy(NonBlocking("AWS SSO bearer token refresher")).build()
private val lastToken = AtomicReference<AccessToken?>()
internal val lastToken = AtomicReference<AccessToken?>()
val pendingAuthorization: PendingAuthorization?
get() = accessTokenProvider.authorization

Expand All @@ -134,6 +136,7 @@
)
}

// we need to seed CachedSupplier with an initial value, then subsequent calls need to hit the network
private fun refreshToken(): RefreshResult<out SdkToken> {
val lastToken = lastToken.get() ?: throw NoTokenInitializedException("Token refresh started before session initialized")
val token = if (Duration.between(Instant.now(), lastToken.expiresAt) > Duration.ofMinutes(30)) {
Expand All @@ -148,6 +151,7 @@
.build()
}

// how we expect consumers to obtain a token
override fun resolveToken() = supplier.get()

override fun close() {
Expand All @@ -159,6 +163,7 @@
close()
}

// internal nonsense so we can query the token without triggering a refresh
override fun currentToken() = lastToken.get()

/**
Expand Down Expand Up @@ -189,7 +194,7 @@

class NoTokenInitializedException(message: String) : Exception(message)

public enum class BearerTokenAuthState {
enum class BearerTokenAuthState {
AUTHORIZED,
NEEDS_REFRESH,
NOT_AUTHENTICATED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ abstract class LoginBrowser(

protected val onPendingToken: (InteractiveBearerTokenProvider) -> Unit = { provider ->
startBrowserOpenTimer(provider.startUrl, provider.region, provider.scopes)

projectCoroutineScope(project).launch {
val authorization = pollForAuthorization(provider)
if (authorization != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineComponent({
login(type: LoginOption) {
this.$emit('login', type)
},
emitUiClickTelemetry(elementId: String) {
emitUiClickTelemetry(elementId: string) {
this.$emit('emitUiClickTelemetry', elementId)
}
}
Expand Down
9 changes: 8 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ rootProject.name = "aws-toolkit-jetbrains"
include("detekt-rules")
include("ui-tests")
include("sandbox-all")
include("ui-tests-starter")
when (providers.gradleProperty("ideProfileName").get()) {
"2023.3", "2024.1" -> include("tmp-all")
// FIX_WHEN_MIN_IS_242: `tmp-all` test module no longer needed in 242+
"2023.3", "2024.1" -> {
include("tmp-all")

// only available 242+
project(":ui-tests-starter").projectDir = file("noop")
}
}

/*
Expand Down
1 change: 1 addition & 0 deletions ui-tests-starter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allure-results/
60 changes: 60 additions & 0 deletions ui-tests-starter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import software.aws.toolkits.gradle.findFolders
import software.aws.toolkits.gradle.intellij.IdeVersions

plugins {
id("toolkit-kotlin-conventions")
id("toolkit-intellij-plugin")

id("org.jetbrains.intellij.platform")
}

val ideProfile = IdeVersions.ideProfile(project)

// Add our source sets per IDE profile version (i.e. src-211)
sourceSets {
test {
java.srcDirs(findFolders(project, "tst", ideProfile))
resources.srcDirs(findFolders(project, "tst-resources", ideProfile))
}
}

intellijPlatform {
buildSearchableOptions = false
instrumentCode = false
}

val testPlugins by configurations.registering

dependencies {
testImplementation(platform("com.jetbrains.intellij.tools:ide-starter-squashed"))
// should really be set by the BOM, but too much work to figure out right now
testImplementation("org.kodein.di:kodein-di-jvm:7.20.2")
intellijPlatform {
intellijIdeaCommunity(IdeVersions.ideProfile(providers).map { it.name })

testFramework(TestFrameworkType.Starter)
}

testPlugins(project(":plugin-amazonq", "pluginZip"))
testPlugins(project(":plugin-core", "pluginZip"))
}

tasks.test {
dependsOn(testPlugins)

useJUnitPlatform()

systemProperty("ui.test.plugins", testPlugins.get().asPath)
}

// hack to disable ui tests in ./gradlew check
val action = Action<TaskExecutionGraph> {
if (hasTask(tasks.test.get())) {
tasks.test.get().enabled = false
}
}
gradle.taskGraph.whenReady(action)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.uitests

import com.intellij.ide.starter.ci.CIServer
import java.nio.file.Path

object TestCIServer : CIServer {
override val isBuildRunningOnCI: Boolean = System.getenv("CI").toBoolean() == true
override val buildNumber: String = ""
override val branchName: String = ""
override val buildParams: Map<String, String> = mapOf()

override fun publishArtifact(source: Path, artifactPath: String, artifactName: String) {
}

override fun reportTestFailure(testName: String, message: String, details: String) {
println("test: $testName")
println("message: $message")
println("details: $details")
error(message)
}

override fun ignoreTestFailure(testName: String, message: String, details: String) {
}

override fun isTestFailureShouldBeIgnored(message: String) = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.uitests

import com.intellij.ide.starter.ci.CIServer
import java.nio.file.Path

object TestCIServer : CIServer {
override val isBuildRunningOnCI: Boolean = System.getenv("CI").toBoolean() == true
override val buildNumber: String = ""
override val branchName: String = ""
override val buildParams: Map<String, String> = mapOf()

override fun publishArtifact(source: Path, artifactPath: String, artifactName: String) {
}

override fun reportTestFailure(testName: String, message: String, details: String, linkToLogs: String?) {
println("test: $testName")
println("message: $message")
println("details: $details")
error(message)
}

override fun ignoreTestFailure(testName: String, message: String) {
}

override fun isTestFailureShouldBeIgnored(message: String) = false
}
Loading
Loading