ソースを参照

fix traffic analytics test

tags/v0.2.0
Jonathan Cobb 5年前
コミット
2bbdda3dce
2個のファイルの変更14行の追加4行の削除
  1. +11
    -1
      bubble-server/src/main/java/bubble/service/cloud/DeviceIdService.java
  2. +3
    -3
      bubble-server/src/test/resources/models/tests/filter/traffic_analytics.json

+ 11
- 1
bubble-server/src/main/java/bubble/service/cloud/DeviceIdService.java ファイルの表示

@@ -1,7 +1,9 @@
package bubble.service.cloud;

import bubble.dao.account.AccountDAO;
import bubble.dao.device.DeviceDAO;
import bubble.model.device.Device;
import bubble.server.BubbleConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.cobbzilla.util.collection.ExpirationMap;
import org.cobbzilla.util.io.FileUtil;
@@ -34,12 +36,20 @@ public class DeviceIdService {
public static final FilenamePrefixFilter DEVICE_FILE_FILTER = new FilenamePrefixFilter(DEVICE_FILE_PREFIX);

@Autowired private DeviceDAO deviceDAO;
@Autowired private BubbleConfiguration configuration;
@Autowired private AccountDAO accountDAO;

private Map<String, Device> deviceCache = new ExpirationMap<>(MINUTES.toMillis(10));

public Device findDeviceByIp (String ipAddr) {

if (!WG_DEVICES_DIR.exists()) throw invalidEx("err.deviceDir.notFound");
if (!WG_DEVICES_DIR.exists()) {
if (configuration.testMode() && ipAddr.equals("127.0.0.1")) {
// this is a test
return new Device().setAccount(accountDAO.getFirstAdmin().getUuid());
}
throw invalidEx("err.deviceDir.notFound");
}

return deviceCache.computeIfAbsent(ipAddr, ip -> {
try {


+ 3
- 3
bubble-server/src/test/resources/models/tests/filter/traffic_analytics.json ファイルの表示

@@ -5,7 +5,7 @@
"params": {
"fqdn": "foo.example.com",
"uri": "/bar",
"jsCheck": "json.length == 0"
"jsCheck": "json.getMatchers().length == 0"
}
},

@@ -15,7 +15,7 @@
"params": {
"fqdn": "foo.example.com",
"uri": "/baz",
"jsCheck": "json.length == 0"
"jsCheck": "json.getMatchers().length == 0"
}
},

@@ -25,7 +25,7 @@
"params": {
"fqdn": "bar.example.com",
"uri": "/qux",
"jsCheck": "json.length == 0"
"jsCheck": "json.getMatchers().length == 0"
}
},



読み込み中…
キャンセル
保存