-
Notifications
You must be signed in to change notification settings - Fork 4
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 #1346 from scireum/feature/smo/migrate-system-cont…
…roller-test JUNIT: migrate system controller test
- Loading branch information
Showing
2 changed files
with
55 additions
and
51 deletions.
There are no files selected for viewing
51 changes: 0 additions & 51 deletions
51
src/test/java/sirius/web/health/SystemControllerSpec.groovy
This file was deleted.
Oops, something went wrong.
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,55 @@ | ||
/* | ||
* Made with all the love in the world | ||
* by scireum in Remshalden, Germany | ||
* | ||
* Copyright by scireum GmbH | ||
* http://www.scireum.de - info@scireum.de | ||
*/ | ||
|
||
package sirius.web.health | ||
|
||
import io.netty.handler.codec.http.HttpResponseStatus | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import sirius.kernel.BaseSpecification | ||
import sirius.kernel.SiriusExtension | ||
import sirius.kernel.commons.Value | ||
import sirius.kernel.di.Injector | ||
import sirius.web.http.TestRequest | ||
import sirius.web.http.TestResponse | ||
import sirius.web.security.UserContext | ||
import sirius.web.security.UserInfo | ||
import java.util.* | ||
import kotlin.test.assertEquals | ||
|
||
@ExtendWith(SiriusExtension::class) | ||
class SystemControllerTest { | ||
|
||
@Test | ||
fun ` system ok returns 200 OK`() { | ||
val result = TestRequest.GET("/system/ok").execute() | ||
assertEquals(HttpResponseStatus.OK, result.getStatus()) | ||
} | ||
|
||
@Test | ||
fun ` system state renders its template`() { | ||
UserContext.get().setCurrentUser( | ||
UserInfo.Builder.createUser("test") | ||
.withPermissions(Collections.singleton(SystemController.PERMISSION_SYSTEM_STATE)).build() | ||
) | ||
val result = TestRequest.GET("/system/state").execute() | ||
assertEquals(HttpResponseStatus.OK, result.getStatus()) | ||
assertEquals(TestResponse.ResponseType.TEMPLATE, result.getType()) | ||
assertEquals("/templates/system/state.html.pasta", result.getTemplateName()) | ||
assertEquals( Injector.context().getPart(Cluster::class.java), Value.indexOf(0, result.getTemplateParameters()).get()) | ||
} | ||
|
||
@Test | ||
fun ` system info renders its template`() { | ||
val result = TestRequest.GET("/system/info").execute() | ||
assertEquals(HttpResponseStatus.OK, result.getStatus()) | ||
assertEquals(TestResponse.ResponseType.TEMPLATE, result.getType()) | ||
assertEquals("/templates/system/info.html.pasta", result.getTemplateName()) | ||
} | ||
|
||
} |