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 {
225225 val client = CoderRestClient (context, URL (url), " token" )
226226 assertEquals(user.username, runBlocking { client.me() }.username)
227227
228- val tests = listOf (" invalid" , null )
228+ val tests = listOf (" invalid" )
229229 tests.forEach { token ->
230230 val ex =
231231 assertFailsWith(
@@ -238,6 +238,26 @@ class CoderRestClientTest {
238238 srv.stop(0 )
239239 }
240240
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+
241261 @Test
242262 fun testGetsWorkspaces () {
243263 val tests =
You can’t perform that action at this time.
0 commit comments