feat: add dedicated DDS permission backoffice instance
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.cloudhandson.ddsbackoffice.config;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DdsPropertiesTest {
|
||||
|
||||
@Test
|
||||
void normalizesObjectsAndUserKeys() {
|
||||
var properties = new DdsProperties(
|
||||
"jdbc:test",
|
||||
Duration.ofSeconds(5),
|
||||
"admin.v_dds_customers_pg",
|
||||
"admin.v_dds_customers_my",
|
||||
Map.of("MY", new DdsProperties.User("MY", "source", "ddsuser_my", "secret"))
|
||||
);
|
||||
|
||||
assertEquals("ADMIN.V_DDS_CUSTOMERS_PG", properties.objectFor("pg"));
|
||||
assertEquals("ADMIN.V_DDS_CUSTOMERS_MY", properties.objectFor("MY"));
|
||||
assertTrue(properties.users().containsKey("my"));
|
||||
assertTrue(properties.users().get("my").configured());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsUnsafeObjectNames() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new DdsProperties(
|
||||
"jdbc:test", Duration.ofSeconds(5), "ADMIN.VIEW;DROP", "ADMIN.VIEW", Map.of()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.cloudhandson.ddsbackoffice.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.cloudhandson.ddsbackoffice.config.DdsProperties;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DdsQueryServiceTest {
|
||||
|
||||
@Test
|
||||
void reportsMissingDatabaseConfigurationWithoutOpeningAConnection() {
|
||||
var properties = new DdsProperties(
|
||||
"", Duration.ofSeconds(5), "ADMIN.V_DDS_CUSTOMERS_PG", "ADMIN.V_DDS_CUSTOMERS_MY",
|
||||
Map.of("my", new DdsProperties.User("MY", "source", "ddsuser_my", "secret"))
|
||||
);
|
||||
|
||||
var result = new DdsQueryService(properties).query("my", "PG", "", 20);
|
||||
|
||||
assertFalse(result.success());
|
||||
assertTrue(result.title().contains("DB 접속"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsUnknownSourceBeforeOpeningAConnection() {
|
||||
var properties = new DdsProperties(
|
||||
"jdbc:test", Duration.ofSeconds(5), "ADMIN.V_DDS_CUSTOMERS_PG", "ADMIN.V_DDS_CUSTOMERS_MY",
|
||||
Map.of("my", new DdsProperties.User("MY", "source", "ddsuser_my", "secret"))
|
||||
);
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new DdsQueryService(properties).query("my", "RDS", "", 20));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user