Skip to content

Commit

Permalink
test: adds controller test that checks access is considered
Browse files Browse the repository at this point in the history
  • Loading branch information
jbee committed Oct 21, 2024
1 parent 6a72ec2 commit bace543
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static org.hisp.dhis.test.utils.Assertions.assertGreaterOrEqual;
import static org.hisp.dhis.test.utils.Assertions.assertLessOrEqual;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.http.MediaType.TEXT_HTML_VALUE;
Expand All @@ -43,6 +44,7 @@
import java.nio.file.Path;
import java.util.List;
import org.hisp.dhis.jsontree.JsonMixed;
import org.hisp.dhis.jsontree.JsonNodeType;
import org.hisp.dhis.jsontree.JsonObject;
import org.hisp.dhis.test.webapi.H2ControllerIntegrationTestBase;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -149,6 +151,28 @@ void testGetOpenApiDocument_DefaultValue() {
assertEquals(50, pageSize.getNumber("schema.default").integer());
}

@Test
void testGetOpenApiDocument_ReadOnly() {
JsonObject doc = GET("/openapi/openapi.json?domain=JobConfiguration").content();
JsonObject jobConfiguration = doc.getObject("components.schemas.JobConfiguration");
JsonObject jobConfigurationParams = doc.getObject("components.schemas.JobConfigurationParams");
assertTrue(jobConfiguration.isObject());
assertTrue(jobConfigurationParams.isObject());
assertTrue(
jobConfiguration.getObject("properties").size()
> jobConfigurationParams.getObject("properties").size());
assertTrue(
jobConfiguration
.node()
.find(JsonNodeType.BOOLEAN, n -> n.getPath().toString().endsWith("readOnly"))
.isPresent());
assertFalse(
jobConfigurationParams
.node()
.find(JsonNodeType.BOOLEAN, n -> n.getPath().toString().endsWith("readOnly"))
.isPresent());
}

@Test
void testGetOpenApiDocument_CodeGeneration() throws IOException {
JsonObject doc = GET("/openapi/openapi.json?failOnNameClash=true").content();
Expand Down

0 comments on commit bace543

Please sign in to comment.