Skip to content

Commit 9df1e99

Browse files
Add smoke test
1 parent 35f4f61 commit 9df1e99

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package datadog.smoketest.dynamicconfig;
2+
3+
import java.util.concurrent.TimeUnit;
4+
5+
public class AppSecApplication {
6+
7+
public static final long TIMEOUT_IN_SECONDS = 10;
8+
9+
public static void main(String[] args) throws InterruptedException {
10+
// just wait as we want to test RC payloads
11+
Thread.sleep(TimeUnit.SECONDS.toMillis(TIMEOUT_IN_SECONDS));
12+
System.exit(0);
13+
}
14+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package datadog.smoketest
2+
3+
import datadog.smoketest.dynamicconfig.AppSecApplication
4+
5+
class AppSecActivationSmokeTest extends AbstractSmokeTest {
6+
7+
@Override
8+
ProcessBuilder createProcessBuilder() {
9+
def command = [javaPath()]
10+
command += defaultJavaProperties.toList()
11+
command += [
12+
'-Ddd.remote_config.enabled=true',
13+
"-Ddd.remote_config.url=http://localhost:${server.address.port}/v0.7/config".toString(),
14+
'-Ddd.remote_config.poll_interval.seconds=1',
15+
'-cp',
16+
System.getProperty('datadog.smoketest.shadowJar.path'),
17+
AppSecApplication.name
18+
]
19+
20+
final processBuilder = new ProcessBuilder(command)
21+
processBuilder.directory(new File(buildDirectory))
22+
}
23+
24+
void 'test activation config change is sent via RC'() {
25+
when:
26+
setRemoteConfig('datadog/2/ASM_FEATURES/asm_features_activation/config', '{"asm":{"enabled":true}}')
27+
28+
then:
29+
waitForTelemetryFlat {
30+
if (it['request_type'] != 'app-client-configuration-change') {
31+
return false
32+
}
33+
final payload = (Map<String, Object>) it['payload']
34+
final configurations = (List<Map<String, Object>>) payload['configuration']
35+
final enabled = configurations.find { it['name'] == 'appsec_enabled' }
36+
return enabled['value'] == 'true' && enabled['origin'] == 'remote_config'
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)