-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
33 lines (29 loc) · 919 Bytes
/
test.py
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
import logging
import urllib.request
logging.info("SentinelOne Test Script")
# General params
token = params.get("connect_sentinelone_api_token")
server = params.get("connect_sentinelone_server")
headers = {
"User-Agent": "FSCT/1.16.2020",
"Accept": "*/*",
"Cache-Control": "no-cache",
"charset": "utf-8",
"Connection": "keep-alive",
}
# Set response
response = {}
# Call resource
request = urllib.request.Request(
server + "/web/api/v2.1/accounts?limit=1&countOnly=true&ApiToken=" + token, headers=headers,
)
# Read resource response
resp = urllib.request.urlopen(request)
if resp.getcode() == 200:
logging.debug("Test: Succeeded")
response["succeeded"] = True
response["result_msg"] = "Successfull connected to SentinelOne Server."
else:
logging.debug("Test: Failed")
response["succeeded"] = False
response["result_msg"] = "Could not connect to SentinelOne Server"