UNPKG

splunk-sdk

Version:

SDK for usage with the Splunk REST API

126 lines (119 loc) 4.23 kB
<!DOCTYPE html> <html> <head> <title>Splunk SDK Browser Tests</title> <link rel="stylesheet" href="../node_modules/mocha/mocha.css"> <link rel="stylesheet" type="text/css" href="../contrib/mocha/browser_test.css"> <script type="text/javascript" src="../client/splunk.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> var http = new splunkjs.ProxyHttp("/proxy"); var options={}; var svc; var loggedOutSvc; pollUntil = async function (obj, condition, iterations) { let i = 0; try { await utils.whilst( function () { return !condition(obj) && (i++ < iterations); }, async function () { await utils.sleep(500); obj.fetch(); } ); } catch (error) { return [error, obj]; } }; DummyHttp = { // Required by Context.init() _setSplunkVersion: function(version) { // nothing } }; $(function() { $("#run-button").click(async function(e) { e.preventDefault(); var scheme = $("#server-scheme").val() || "https"; var host = $("#server-host").val() || "localhost"; var port = $("#server-port").val() || "8089"; var username = $("#server-username").val() || "admin"; var password = $("#server-password").val() || "changed!"; var version = $("#server-version").val() || "8.2.4"; options = { scheme: scheme, host: host, port: port, username: username, password: password, version: version }; loggedOutSvc = new splunkjs.Service(http, { scheme: options.scheme, host: options.host, port: options.port, username: options.username, password: options.password + 'wrong', version: options.version }); svc = new splunkjs.Service(http, options); try { await svc.login(); mocha.run(); } catch (error) { alert("Cannot run tests - login failed"); } }); }); </script> </head> <body> <div class="header"> <h1 id="browser_test-header">Splunk SDK Browser Test Suite</h1> <div id="server-info-form"> <div class="server-info-field"> <h3>Scheme</h3> <input id="server-scheme" value="https"/> </div> <div class="server-info-field"> <h3>Host</h3> <input id="server-host" value="localhost"/> </div> <div class="server-info-field"> <h3>Port</h3> <input id="server-port" value="8089"/> </div> <div class="server-info-field"> <h3>Username</h3> <input id="server-username" value="admin"/> </div> <div class="server-info-field"> <h3>Password</h3> <input type="password" id="server-password" value="changed!"/> </div> <div class="server-info-field"> <h3>Version</h3> <input type="text" id="server-version" value="8.2.4"/> </div> <div class="server-info-field"> <h3>&nbsp;</h3> <a class="btn success" id="run-button" href="">Run</a> </div> </div> <div class="clearfix"></div> </div> <div id="mocha"></div> <script src="../node_modules/mocha/mocha.js"></script> <script src="../node_modules/chai/chai.js"></script> <script> mocha.setup('bdd') mocha.timeout('10s'); </script> <script src="../client/browser_utils.js"></script> <script src="../client/browser_service.js"></script> <script src="../client/browser_context.js"></script> <!-- Note that we cannot run the following tests in the browser, as they depend on capabilities of node.js: - HTTP tests (require cross-domain) --> </body> </html>