Files
ManuAgent/server/src/test/java/tech/easyflow/manuagent/KeyCipherAndShellTest.java
Zhu Junhao 988c0fe555 feat: 完善多模型配置与运行切换
将模型连接统一持久化管理,并支持 Agent 运行中切换模型以及中断后选择模型继续。补充配置校验、事务与前后端交互测试。
2026-09-03 10:46:25 +08:00

36 lines
1.1 KiB
Java

package tech.easyflow.manuagent;
import static org.assertj.core.api.Assertions.assertThat;
import tech.easyflow.manuagent.config.AppProperties;
import tech.easyflow.manuagent.model.KeyCipher;
import java.nio.file.Path;
import java.time.Duration;
import org.junit.jupiter.api.Test;
/**
* 验证模型密钥保护。
*/
class KeyCipherAndShellTest {
/**
* 验证密钥可恢复且相同明文每次产生不同密文。
*/
@Test
void shouldEncryptModelKeyWithRandomIv() {
KeyCipher cipher = new KeyCipher(properties());
byte[] first = cipher.encrypt("local-test-key");
byte[] second = cipher.encrypt("local-test-key");
assertThat(first).isNotEqualTo(second);
assertThat(cipher.decrypt(first)).isEqualTo("local-test-key");
}
private AppProperties properties() {
return new AppProperties(
Path.of("data"), Path.of("dashscope"),
"unit-test-master", "admin", "admin123",
"smart-factory-agent-runtime:test", "bridge", Duration.ofMinutes(1));
}
}