File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/test/kotlin/com/coder/toolbox/sdk Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ class CoderRestClientTest {
225
225
val client = CoderRestClient (context, URL (url), " token" )
226
226
assertEquals(user.username, runBlocking { client.me() }.username)
227
227
228
- val tests = listOf (" invalid" , null )
228
+ val tests = listOf (" invalid" )
229
229
tests.forEach { token ->
230
230
val ex =
231
231
assertFailsWith(
@@ -238,6 +238,26 @@ class CoderRestClientTest {
238
238
srv.stop(0 )
239
239
}
240
240
241
+ @Test
242
+ fun `exception is raised when token is required for authentication and token value is null or empty` () {
243
+ listOf (" " , null ).forEach { token ->
244
+ val ex =
245
+ assertFailsWith(
246
+ exceptionClass = IllegalStateException ::class ,
247
+ block = {
248
+ runBlocking {
249
+ CoderRestClient (
250
+ context,
251
+ URI .create(" https://coder.com" ).toURL(),
252
+ token
253
+ ).me()
254
+ }
255
+ },
256
+ )
257
+ assertEquals(ex.message, " Token is required for https://coder.com deployment" )
258
+ }
259
+ }
260
+
241
261
@Test
242
262
fun testGetsWorkspaces () {
243
263
val tests =
You can’t perform that action at this time.
0 commit comments