Add initial project configuration and test setup
This commit is contained in:
parent
178e16627f
commit
7d2b2242aa
9 changed files with 110 additions and 0 deletions
11
tests/ping.http
Normal file
11
tests/ping.http
Normal file
|
@ -0,0 +1,11 @@
|
|||
< {%
|
||||
import {randomCrc32String} from "./utilities.js";
|
||||
request.variables.set("id", randomCrc32String());
|
||||
%}
|
||||
POST http://172.27.7.211/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"method": "ping",
|
||||
"id": "{{id}}"
|
||||
}
|
33
tests/utilities.js
Normal file
33
tests/utilities.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
export function crc32(str) {
|
||||
var crcTable = [];
|
||||
for (var i = 0; i < 256; i++) {
|
||||
var crc = i;
|
||||
for (var j = 8; j > 0; j--) {
|
||||
if (crc & 1) {
|
||||
crc = (crc >>> 1) ^ 0xEDB88320;
|
||||
} else {
|
||||
crc = crc >>> 1;
|
||||
}
|
||||
}
|
||||
crcTable[i] = crc;
|
||||
}
|
||||
|
||||
var crc32val = 0xFFFFFFFF;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var charCode = str.charCodeAt(i);
|
||||
crc32val = (crc32val >>> 8) ^ crcTable[(crc32val ^ charCode) & 0xFF];
|
||||
}
|
||||
|
||||
return (crc32val ^ 0xFFFFFFFF) >>> 0;
|
||||
}
|
||||
|
||||
export function randomCrc32String(length = 8) {
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var randomStr = '';
|
||||
for (var i = 0; i < length; i++) {
|
||||
randomStr += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
return crc32(randomStr).toString(16); // Convert to hexadecimal string
|
||||
}
|
||||
|
||||
console.log(randomCrc32String()); // Example usage
|
Loading…
Add table
Add a link
Reference in a new issue