Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(amazonq): rename cwsprEndpointCustomizer -> ClientCustomizer #5340

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</extensions>

<extensions defaultExtensionNs="aws.toolkit.core">
<sdk.clientCustomizer implementation="software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererEndpointCustomizer"/>
<sdk.clientCustomizer implementation="software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererClientCustomizer"/>
</extensions>

<extensions defaultExtensionNs="amazon.q.codewhisperer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package software.aws.toolkits.jetbrains.services.codewhisperer.util

import com.intellij.openapi.application.ApplicationManager
import com.intellij.util.net.HttpConfigurable

Check failure on line 7 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'com.intellij.util.net.HttpConfigurable' is deprecated and marked for removal
import com.intellij.util.net.ssl.CertificateManager
import com.intellij.util.proxy.CommonProxy
import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider
Expand Down Expand Up @@ -34,7 +34,7 @@
import javax.net.ssl.TrustManager

// TODO: move this file to package /client
class CodeWhispererEndpointCustomizer : ToolkitClientCustomizer {
class CodeWhispererClientCustomizer : ToolkitClientCustomizer {

Check warning on line 37 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Extension class should be final and non-public

Extension class should not be public

Check warning

Code scanning / QDJVMC

Extension class should be final and non-public Warning

Extension class should not be public

override fun customize(
credentialProvider: AwsCredentialsProvider?,
Expand Down Expand Up @@ -76,20 +76,20 @@
error("Q Chat HTTP client does not support SOCKS proxies")
} else if (address is java.net.InetSocketAddress) {
val proxyConfiguration = ProxyConfiguration.builder()
.host(address.getHostName())

Check notice on line 79 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Accessor call that can be replaced with property access syntax

Use of getter method instead of property access syntax
.port(address.getPort())

Check notice on line 80 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Accessor call that can be replaced with property access syntax

Use of getter method instead of property access syntax
.apply {
val configurable = HttpConfigurable.getInstance()

Check failure on line 82 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'com.intellij.util.net.HttpConfigurable' is deprecated and marked for removal

Check failure on line 82 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'com.intellij.util.net.HttpConfigurable' is deprecated and marked for removal
val proxyExceptions = configurable.PROXY_EXCEPTIONS

Check failure on line 83 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'PROXY_EXCEPTIONS' is deprecated and marked for removal
if (!proxyExceptions.isNullOrBlank()) {
// should be handled by CommonProxy, but also should be no harm in passing this along if something more complicated is happening
nonProxyHosts(proxyExceptions.split(',').toSet())
}

val login = HttpConfigurable.getInstance().proxyLogin

Check failure on line 89 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'getProxyLogin()' is deprecated and marked for removal

Check failure on line 89 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'com.intellij.util.net.HttpConfigurable' is deprecated and marked for removal

Check failure on line 89 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'com.intellij.util.net.HttpConfigurable' is deprecated and marked for removal
if (login != null) {
username(login)
password(HttpConfigurable.getInstance().plainProxyPassword)

Check failure on line 92 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'getPlainProxyPassword()' is deprecated and marked for removal

Check failure on line 92 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'com.intellij.util.net.HttpConfigurable' is deprecated and marked for removal

Check failure on line 92 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererClientCustomizer.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of API marked for removal

'com.intellij.util.net.HttpConfigurable' is deprecated and marked for removal
}
}
.useSystemPropertyValues(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import software.aws.toolkits.jetbrains.core.AwsClientManager
import software.aws.toolkits.jetbrains.core.MockClientManager.Companion.useRealImplementations
import java.util.concurrent.CountDownLatch

class CodeWhispererEndpointCustomizerTest {
class CodeWhispererClientCustomizerTest {
@Rule
@JvmField
val application = ApplicationRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import software.aws.toolkits.jetbrains.core.MockClientManager
import software.aws.toolkits.jetbrains.core.MockClientManagerRule
import software.aws.toolkits.jetbrains.core.credentials.MockCredentialManagerRule
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererEndpointCustomizer
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererClientCustomizer
import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings

/**
* If this test class failed, highly likely because the endpoint is overwritten by [CodeWhispererEndpointCustomizer]
* If this test class failed, highly likely because the endpoint is overwritten by [CodeWhispererClientCustomizer]
*/
class CodeWhispererClientTest {
val applicationRule = ApplicationRule()
Expand Down Expand Up @@ -90,8 +90,8 @@ class CodeWhispererClientTest {
mockClient.getAccessToken {}
verify(
postRequestedFor(urlEqualTo("/"))
.withoutHeader(CodeWhispererEndpointCustomizer.OPTOUT_KEY_NAME)
.withoutHeader(CodeWhispererEndpointCustomizer.OPTOUT_KEY_NAME)
.withoutHeader(CodeWhispererClientCustomizer.OPTOUT_KEY_NAME)
.withoutHeader(CodeWhispererClientCustomizer.OPTOUT_KEY_NAME)
)
}

Expand All @@ -101,16 +101,16 @@ class CodeWhispererClientTest {
// default is opt-in (thus opt-out = false)
verify(
postRequestedFor(urlEqualTo("/"))
.withHeader(CodeWhispererEndpointCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withHeader(CodeWhispererEndpointCustomizer.OPTOUT_KEY_NAME, matching("false"))
.withHeader(CodeWhispererClientCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withHeader(CodeWhispererClientCustomizer.OPTOUT_KEY_NAME, matching("false"))
)

CodeWhispererSettings.getInstance().toggleMetricOptIn(false)
mockClient.listRecommendations {}
verify(
postRequestedFor(urlEqualTo("/"))
.withHeader(CodeWhispererEndpointCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withHeader(CodeWhispererEndpointCustomizer.OPTOUT_KEY_NAME, matching("true"))
.withHeader(CodeWhispererClientCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withHeader(CodeWhispererClientCustomizer.OPTOUT_KEY_NAME, matching("true"))
)
}

Expand All @@ -119,8 +119,8 @@ class CodeWhispererClientTest {
mockClient.createCodeScan {}
verify(
postRequestedFor(urlEqualTo("/"))
.withHeader(CodeWhispererEndpointCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withoutHeader(CodeWhispererEndpointCustomizer.OPTOUT_KEY_NAME)
.withHeader(CodeWhispererClientCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withoutHeader(CodeWhispererClientCustomizer.OPTOUT_KEY_NAME)

)
}
Expand All @@ -130,8 +130,8 @@ class CodeWhispererClientTest {
mockClient.createCodeScanUploadUrl {}
verify(
postRequestedFor(urlEqualTo("/"))
.withHeader(CodeWhispererEndpointCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withoutHeader(CodeWhispererEndpointCustomizer.OPTOUT_KEY_NAME)
.withHeader(CodeWhispererClientCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withoutHeader(CodeWhispererClientCustomizer.OPTOUT_KEY_NAME)
)
}

Expand All @@ -140,8 +140,8 @@ class CodeWhispererClientTest {
mockClient.listCodeScanFindings {}
verify(
postRequestedFor(urlEqualTo("/"))
.withHeader(CodeWhispererEndpointCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withoutHeader(CodeWhispererEndpointCustomizer.OPTOUT_KEY_NAME)
.withHeader(CodeWhispererClientCustomizer.TOKEN_KEY_NAME, matching(CodeWhispererTestUtil.testValidAccessToken))
.withoutHeader(CodeWhispererClientCustomizer.OPTOUT_KEY_NAME)
)
}
}
Loading