-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from modelix/MODELIX-745
feat(instances-manager): add generic redirection route to ports
- Loading branch information
Showing
4 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
instances-manager/src/test/kotlin/org/modelix/instancesmanager/RedirectedURLTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.modelix.instancesmanager | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNull | ||
|
||
class RedirectedURLTest { | ||
|
||
fun createRedirectUrlToPort(portString: String, pathAfterPort: String): RedirectedURL { | ||
return RedirectedURL( | ||
remainingPath = "/port/$portString$pathAfterPort", | ||
workspaceReference = "workspace", | ||
sharedInstanceName = "own", | ||
instanceName = null, | ||
userToken = null | ||
) | ||
} | ||
|
||
@Test | ||
fun `create redirect URL for valid port number with path after port`() { | ||
val redirectedURL = createRedirectUrlToPort("65535", "/some_path") | ||
assertEquals("http://workspace:65535/some_path", redirectedURL.getURLToRedirectTo(false)) | ||
} | ||
|
||
@Test | ||
fun `create redirect URL for valid port number without path after port`() { | ||
val redirectedURL = createRedirectUrlToPort("65535", "") | ||
assertEquals("http://workspace:65535", redirectedURL.getURLToRedirectTo(false)) | ||
} | ||
|
||
|
||
@Test | ||
fun `do no create redirect URL for port that is out of range`() { | ||
val redirectedURL = createRedirectUrlToPort("65536", "") | ||
assertNull(redirectedURL.getURLToRedirectTo(false)) | ||
} | ||
|
||
@Test | ||
fun `do no create redirect URL for port that is not a number`() { | ||
val redirectedURL = createRedirectUrlToPort("not_a_number", "") | ||
assertNull(redirectedURL.getURLToRedirectTo(false)) | ||
} | ||
} |