Skip to content

Commit e923b37

Browse files
committed
stream assert
1 parent c057ab7 commit e923b37

File tree

1 file changed

+11
-2
lines changed
  • plugins/amazonq/shared/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/lsp/encryption

1 file changed

+11
-2
lines changed

plugins/amazonq/shared/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/lsp/encryption/JwtEncryptionManagerTest.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package software.aws.toolkits.jetbrains.services.amazonq.lsp.encryption
66
import org.assertj.core.api.Assertions.assertThat
77
import org.junit.jupiter.api.Test
88
import java.io.ByteArrayOutputStream
9+
import java.util.concurrent.atomic.AtomicBoolean
910
import javax.crypto.spec.SecretKeySpec
1011
import kotlin.random.Random
1112

@@ -40,18 +41,26 @@ class JwtEncryptionManagerTest {
4041
val bytes = "DEADBEEF".repeat(8).hexToByteArray() // 32 bytes
4142
val key = SecretKeySpec(bytes, "HmacSHA256")
4243

43-
val os = ByteArrayOutputStream()
44+
val closed = AtomicBoolean(false)
45+
val os = object : ByteArrayOutputStream() {
46+
override fun close() {
47+
closed.set(true)
48+
}
49+
}
4450
JwtEncryptionManager(key).writeInitializationPayload(os)
4551
assertThat(os.toString())
4652
// Flare requires encryption ends with new line
4753
// https://github.com/aws/language-server-runtimes/blob/4d7f81295dc12b59ed2e1c0ebaedb85ccb86cf76/runtimes/README.md#encryption
4854
.endsWith("\n")
49-
// language=JSON
5055
.isEqualTo(
56+
// language=JSON
5157
"""
5258
|{"version":"1.0","mode":"JWT","key":"3q2-796tvu_erb7v3q2-796tvu_erb7v3q2-796tvu8"}
5359
|
5460
""".trimMargin()
5561
)
62+
63+
// writeInitializationPayload should not close the stream
64+
assertThat(closed.get()).isFalse
5665
}
5766
}

0 commit comments

Comments
 (0)