修改prepare.sh以便进行docker创建

This commit is contained in:
EnderByEndera
2024-01-23 15:44:18 +08:00
parent 389483989c
commit 84cbf3be89
2 changed files with 25 additions and 13 deletions

View File

@@ -1,7 +1,10 @@
#!/usr/bin/env bash
cd ~
# 初始化变量设定
export set BASEDIR="/root"
export set PROTECTION_DIR="$BASEDIR/realtime_protection"
# 下载必须依赖
bash -c "cat << EOF > /etc/apt/sources.list && apt update
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
@@ -14,13 +17,17 @@ deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted univers
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF"
apt install sudo vim git wget openjdk-17-jdk -y
apt install sudo git wget openjdk-17-jdk -y
git config --global user.name "EnderByEndera"
git config --global user.password "8Bs8hxHtE-iq44g"
git clone https://git.mesalab.cn/EnderByEndera/realtime_protection.git
# 下载git仓库内容
echo https://EnderByEndera:8Bs8hxHtE-iq44g@git.mesalab.cn > $BASEDIR/.git-credentials
git config --global credential.helper store
git clone https://git.mesalab.cn/EnderByEndera/realtime_protection.git $BASEDIR/realtime_protection
# 启动gradle编译java
cd realtime_protection
./gradlew clean && ./gradlew bootJar
chmod +x $PROTECTION_DIR/gradlew
$PROTECTION_DIR/gradlew clean && $PROTECTION_DIR/gradlew build
# 启动SpringBoot开启服务
# java -jar $PROTECTION_DIR/build/libs/protection-0.0.3-SNAPSHOT.jar --spring.profiles.active=prod

View File

@@ -25,7 +25,6 @@ class TaskServiceTest extends ProtectionApplicationTests {
private final TaskService taskService;
private final StaticRuleService staticRuleService;
private final DynamicRuleService dynamicRuleService;
private final StateChangeService stateChangeService;
private Task task;
@Autowired
@@ -33,7 +32,6 @@ class TaskServiceTest extends ProtectionApplicationTests {
this.taskService = taskService;
this.staticRuleService = staticRuleService;
this.dynamicRuleService = dynamicRuleService;
this.stateChangeService = stateChangeService;
}
@BeforeEach
@@ -97,13 +95,20 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testUpdateTasks() {
Task originalTask = taskService.queryTask(38L);
Task originalTask = taskService.queryTasks(
null, null, null, null, 1, 1)
.get(0);
originalTask.setStaticRuleIds(List.of(16, 17, 18, 19));
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
null, null, null, null, 1, 4
);
List<Integer> staticRuleIds = new ArrayList<>();
staticRuleObjects.forEach(staticRuleObject -> staticRuleIds.add(staticRuleObject.getStaticRuleId()));
originalTask.setStaticRuleIds(staticRuleIds);
originalTask.setTaskName("修改测试");
assertTrue(taskService.updateTask(originalTask));
assertEquals("修改测试", taskService.queryTask(38L).getTaskName());
assertEquals("修改测试", taskService.queryTask(originalTask.getTaskId()).getTaskName());
}
@Test