Skip to content

Commit

Permalink
add some tests (arkime#2828)
Browse files Browse the repository at this point in the history
* add some tests

* forgot to include
  • Loading branch information
awick authored Jun 7, 2024
1 parent 46a7098 commit 765b396
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"cont3xt:lint": "eslint --ext .js,.vue cont3xt common",
"cont3xt:testui": "cd cont3xt && jest",
"doc": "npm run common:doc && npm run cont3xt:doc && npm run viewer:doc && npm run wise:doc",
"esproxy:dev": "cd viewer && NODE_ENV=development nodemon esProxy.js -c ../tests/config.test.ini -n esproxy",
"viewer:addtestuser": "cd viewer && node addUser.js -c ../tests/config.test.ini -n testuser admin admin admin --admin --packetSearch",
"viewer:build": "cd viewer && node vueapp/build/build.js",
"viewer:bundle": "webpack --progress --config viewer/vueapp/build/webpack.dev.conf.js",
Expand Down
17 changes: 16 additions & 1 deletion tests/api-stats.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Test::More tests => 87;
use Test::More tests => 92;
use Cwd;
use URI::Escape;
use ArkimeTest;
Expand Down Expand Up @@ -160,6 +160,21 @@ my $test1Token = getTokenCookie("test1");
$shards = multiGet("/api/esshards?show=all&cluster=unknown");
eq_or_diff($shards, from_json('{"success": false, "text": "No results"}'));

$result = viewerPostToken("/api/esshards/theindex/0/delete", "", $token);
eq_or_diff($result, from_json('{"success": false, "text": "Deleting shard theindex:0 failed"}'), "esshard: delete failed");

$result = viewerPostToken("/api/esshards/theindex/theshard/delete?arkimeRegressionUser=test1", "", $test1Token);
eq_or_diff($result, from_json('{"success": false, "text": "You do not have permission to access this resource"}'), "esshard: delete not admin");

$result = multiPostToken("/api/esshards/theindex/0/delete", "", $token);
eq_or_diff($result, from_json('{"success": false, "text": "Missing cluster in multiES mode"}'));

$result = multiPostToken("/api/esshards/theindex/0/delete?cluster=unknown", "", $token);
eq_or_diff($result, from_json('{"success": false, "text": "Deleting shard theindex:0 failed"}'));

$result = multiPostToken("/api/esshards/theindex/theshard/delete?arkimeRegressionUser=test1&cluster=unknown", "", $test1Token);
eq_or_diff($result, from_json('{"success": false, "text": "You do not have permission to access this resource"}'), "esshard: delete not admin");

# esrecovery
my $recovery = viewerGet("/api/esrecovery?show=all");
cmp_ok (@{$recovery->{data}}, ">=", 100, "recovery array size");
Expand Down
2 changes: 1 addition & 1 deletion viewer/apiStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ class StatsAPIs {
*/
static async deleteESShard (req, res) {
if (internals.multiES && req.query.cluster === undefined) {
return res.serverError(401, 'Not supported in multies');
return res.serverError(401, 'Missing cluster in multiES mode');
}

try {
Expand Down

0 comments on commit 765b396

Please sign in to comment.