Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
* port-forwarding: # 생략하면 NodePort를 그대로 안내
* node-port-base: 30000
* public-port-base: 9300
* size: 98
* size: 80
* LAB:
* public-host: 203.0.113.10
* admin-channel: lab-admin
* port-forwarding:
* node-port-base: 30100
* public-port-base: 9400
* size: 2668
* </pre>
*
* <p>같은 키 이름으로 {@code slack-channel-id.<키>}에 Slack 채널 ID를 적어 두면(선택) 신청서를 봇으로 올리고, 그 신청의
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ private static ServerProfileRegistry registry(Map<String, Server> servers) {
}

private static final Server FARM = new Server("farm.example.org", "farm-admin", null,
new PortForwarding(30000, 9300, 98));
new PortForwarding(30000, 9300, 80));
private static final Server LAB = new Server("lab.example.org", "lab-admin", null,
new PortForwarding(30100, 9400, 2668));

@Test
@DisplayName("서버 이름은 대소문자·앞뒤 공백을 가리지 않고 찾는다")
Expand Down Expand Up @@ -64,12 +66,26 @@ void publicPortMapsOnlyInsideBand() {
ServerProfileRegistry registry = registry(Map.of("FARM", FARM));

assertThat(registry.publicPort("FARM", "30000")).isEqualTo("9300");
assertThat(registry.publicPort("FARM", "30097")).isEqualTo("9397");
assertThat(registry.publicPort("FARM", "30098")).isEqualTo("30098");
assertThat(registry.publicPort("FARM", "30079")).isEqualTo("9379");
assertThat(registry.publicPort("FARM", "30080")).isEqualTo("30080");
assertThat(registry.publicPort("FARM", "29999")).isEqualTo("29999");
assertThat(registry.publicPort("FARM", "")).isEmpty();
}

@Test
@DisplayName("LAB 사용자 NodePort 전 구간을 9400부터 같은 오프셋으로 안내한다")
void labPublicPortMapsTheDedicatedBand() {
ServerProfileRegistry registry = new ServerProfileRegistry(
new ServerProfileProperties(Map.of("FARM", FARM, "LAB", LAB)),
new MockEnvironment()
.withProperty("slack-webhook-url.farm-admin", FARM_WEBHOOK)
.withProperty("slack-webhook-url.lab-admin", "https://hooks.slack.com/lab"));

assertThat(registry.publicPort("LAB", "30100")).isEqualTo("9400");
assertThat(registry.publicPort("LAB", "32767")).isEqualTo("12067");
assertThat(registry.publicPort("LAB", "30099")).isEqualTo("30099");
}

@Test
@DisplayName("포워딩 구성이 없는 서버는 NodePort를 그대로 안내한다")
void noForwardingKeepsNodePort() {
Expand Down
6 changes: 5 additions & 1 deletion src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ app:
port-forwarding:
node-port-base: 30000
public-port-base: 9300
size: 98
size: 80
LAB:
public-host: lab.example.test
admin-channel: lab-admin
port-forwarding:
node-port-base: 30100
public-port-base: 9400
size: 2668

provi:
lab-enabled: true
Expand Down
Loading