Skip to content

Commit a9b2f15

Browse files
committed
test with auth
1 parent 4c09587 commit a9b2f15

File tree

3 files changed

+104
-19
lines changed

3 files changed

+104
-19
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package abc
5+
6+
import com.intellij.openapi.Disposable
7+
import com.intellij.openapi.util.Disposer
8+
import com.intellij.testFramework.ApplicationExtension
9+
import com.intellij.testFramework.junit5.TestDisposable
10+
import org.junit.Rule
11+
import org.junit.jupiter.api.AfterEach
12+
import org.junit.jupiter.api.BeforeEach
13+
import org.junit.jupiter.api.Test
14+
import org.junit.jupiter.api.extension.ExtendWith
15+
import software.aws.toolkits.core.rules.SystemPropertyHelper
16+
import software.aws.toolkits.jetbrains.core.credentials.LegacyManagedBearerSsoConnection
17+
import software.aws.toolkits.jetbrains.core.credentials.ManagedBearerSsoConnection
18+
import software.aws.toolkits.jetbrains.core.credentials.sono.Q_SCOPES
19+
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProvider
20+
import software.aws.toolkits.jetbrains.utils.extensions.SsoLogin
21+
import software.aws.toolkits.jetbrains.utils.extensions.SsoLoginExtension
22+
23+
24+
@ExtendWith(ApplicationExtension::class, SsoLoginExtension::class)
25+
@SsoLogin("amazonq-test-account")
26+
//@DisabledIfEnvironmentVariable(named = "IS_PROD", matches = "false")
27+
class AbcTest {
28+
29+
30+
@TestDisposable
31+
private lateinit var disposable: Disposable
32+
33+
34+
@Rule
35+
@JvmField
36+
val systemPropertyHelper = SystemPropertyHelper()
37+
38+
private lateinit var connection: ManagedBearerSsoConnection
39+
40+
41+
42+
@BeforeEach
43+
fun setUp() {
44+
// Setup test environment
45+
System.setProperty("AWS_PROFILE","act_cred")
46+
47+
}
48+
49+
50+
@Test
51+
fun `can set up Connection`() {
52+
println("This ran")
53+
connection = LegacyManagedBearerSsoConnection("start_url", "us-east-1", Q_SCOPES)
54+
//ConnectionPinningManager.getInstance().setPinnedConnection(QConnection.getInstance(), connection)
55+
(connection.getConnectionSettings().tokenProvider.delegate as BearerTokenProvider).reauthenticate()
56+
57+
//Disposer.register(disposable, connection)
58+
// MockClientManager.useRealImplementations(disposableExtension.disposable)
59+
60+
}
61+
62+
63+
64+
}

ui-tests-starter/build.gradle.kts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ plugins {
1313
}
1414

1515
val ideProfile = IdeVersions.ideProfile(project)
16+
val testPlugins by configurations.registering
17+
val testPrep by sourceSets.creating {
18+
java.srcDirs(findFolders(project, "tst-prep", ideProfile))
19+
}
20+
1621

1722
// Add our source sets per IDE profile version (i.e. src-211)
1823
sourceSets {
@@ -27,7 +32,7 @@ intellijPlatform {
2732
instrumentCode = false
2833
}
2934

30-
val testPlugins by configurations.registering
35+
3136

3237
dependencies {
3338
//testImplementation(platform("com.jetbrains.intellij.tools:ide-starter"))
@@ -39,15 +44,18 @@ dependencies {
3944
testImplementation(project(":plugin-core:jetbrains-community"))
4045
testImplementation(project(":plugin-core:core"))
4146
testImplementation(testFixtures(project(":plugin-core:jetbrains-community")))
47+
val testPrepImplementation by configurations.getting
4248

49+
testPrepImplementation(testFixtures(project(":plugin-core:jetbrains-community")))
4350

4451

4552

4653

4754
intellijPlatform {
48-
intellijIdeaCommunity(IdeVersions.ideProfile(providers).map { it.name })
49-
intellijIdeaCommunity(ideProfile.community.sdkVersion)
50-
55+
//intellijIdeaCommunity(IdeVersions.ideProfile(providers).map { it.name })
56+
//intellijIdeaCommunity(ideProfile.community.sdkVersion)
57+
val version = ideProfile.community.sdkVersion
58+
intellijIdeaCommunity(version, !version.contains("SNAPSHOT"))
5159
testFramework(TestFrameworkType.JUnit5)
5260
testFramework(TestFrameworkType.Starter)
5361
testFramework(TestFrameworkType.Bundled)
@@ -57,9 +65,22 @@ dependencies {
5765
testPlugins(project(":plugin-core", "pluginZip"))
5866
}
5967

68+
val prepareAmazonQTest = tasks.register<Test>("prepareAmazonQTest") {
69+
// dependsOn(":plugin-core:jetbrains-community:test:abc")
70+
// filter {
71+
// setIncludePatterns("abc.*")
72+
// //includeTestsMatching("abc.AbcTest")
73+
// //excludeTestsMatching("software.aws.toolkits.jetbrains.*")
74+
// }
75+
testClassesDirs = testPrep.output.classesDirs
76+
classpath = testPrep.runtimeClasspath
77+
78+
useJUnitPlatform()// Assuming your test task is named amazonQTest
79+
}
80+
6081
tasks.test {
6182
dependsOn(testPlugins)
62-
83+
dependsOn(prepareAmazonQTest)
6384
useJUnitPlatform()
6485

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

ui-tests-starter/tst/software/aws/toolkits/jetbrains/uitests/AmazonQChatTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ class AmazonQChatTest {
6464

6565

6666

67-
Paths.get(System.getProperty("user.home"), ".aws", "sso", "cache", "ee1d2538cb8d358377d7661466c866af747a8a3f.json")
68-
.createParentDirectories()
69-
.writeText(
70-
"""
71-
paste your client reg here
72-
""".trimIndent()
73-
)
74-
75-
Paths.get(System.getProperty("user.home"), ".aws", "sso", "cache", "d3b447f809607422aac1470dd17fbb32e358cdb3.json")
76-
.writeText(
77-
"""
78-
paste your access token here
79-
""".trimIndent()
80-
)
67+
// Paths.get(System.getProperty("user.home"), ".aws", "sso", "cache", "ee1d2538cb8d358377d7661466c866af747a8a3f.json")
68+
// .createParentDirectories()
69+
// .writeText(
70+
// """
71+
// paste your client reg here
72+
// """.trimIndent()
73+
// )
74+
//
75+
// Paths.get(System.getProperty("user.home"), ".aws", "sso", "cache", "d3b447f809607422aac1470dd17fbb32e358cdb3.json")
76+
// .writeText(
77+
// """
78+
// paste your access token here
79+
// """.trimIndent()
80+
// )
8181

8282
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
8383
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->

0 commit comments

Comments
 (0)