-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathtests.browser.html
More file actions
126 lines (119 loc) · 4.13 KB
/
Copy pathtests.browser.html
File metadata and controls
126 lines (119 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!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> </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>