Skip to content

Commit ae926d5

Browse files
author
saul-data
committed
sslverify false option for sharepoint testing
1 parent e483b8d commit ae926d5

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/dataplane/Microsoft/Sharepoint/sharepoint_download.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ProxyUrl: Proxy endpoint to use
99
ProxyMethod: https or http, default https
1010
"""
11-
def sharepoint_download(Host, TenantID, ClientID, Secret, SiteName, SharepointFilePath, DownloadMethod="Object", LocalFilePath="", Library="root", ProxyUse=False, ProxyUrl="", ProxyMethod="https"):
11+
def sharepoint_download(Host, TenantID, ClientID, Secret, SiteName, SharepointFilePath, DownloadMethod="Object", LocalFilePath="", Library="root", ProxyUse=False, ProxyUrl="", ProxyMethod="https", SSLVerify=True):
1212

1313
import requests
1414
from datetime import datetime
@@ -37,7 +37,7 @@ def sharepoint_download(Host, TenantID, ClientID, Secret, SiteName, SharepointF
3737
else:
3838
proxies = {}
3939

40-
auth = requests.request("POST", url, headers=headers, data=payload, proxies=proxies)
40+
auth = requests.request("POST", url, headers=headers, data=payload, proxies=proxies, verify=SSLVerify)
4141

4242
if auth.status_code != 200:
4343
duration = datetime.now() - start
@@ -53,7 +53,7 @@ def sharepoint_download(Host, TenantID, ClientID, Secret, SiteName, SharepointF
5353

5454
# ======= Get Site ID from Site name ====
5555
SiteName = SiteName.replace(" ", "")
56-
SiteID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{Host}:/sites/{SiteName}?$select=id", headers=headers, json=payload, proxies=proxies)
56+
SiteID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{Host}:/sites/{SiteName}?$select=id", headers=headers, json=payload, proxies=proxies, verify=SSLVerify)
5757

5858
if SiteID.status_code != 200:
5959
duration = datetime.now() - start
@@ -71,7 +71,7 @@ def sharepoint_download(Host, TenantID, ClientID, Secret, SiteName, SharepointF
7171
else:
7272

7373
drive = ""
74-
driveID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{SiteID['id']}/drives?$select=name,id", headers=headers, json=payload, proxies=proxies)
74+
driveID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{SiteID['id']}/drives?$select=name,id", headers=headers, json=payload, proxies=proxies, verify=SSLVerify)
7575
if driveID.status_code != 200:
7676
duration = datetime.now() - start
7777
return {"result":"Fail", "reason":"Sharepoint get drives", "duration": str(duration), "status": driveID.status_code, "error": driveID.json()}
@@ -91,7 +91,7 @@ def sharepoint_download(Host, TenantID, ClientID, Secret, SiteName, SharepointF
9191
# ====== Get Item ID =====
9292

9393

94-
ItemID = requests.request("GET", url, headers=headers, json=payload, proxies=proxies)
94+
ItemID = requests.request("GET", url, headers=headers, json=payload, proxies=proxies, verify=SSLVerify)
9595

9696
if ItemID.status_code != 200:
9797
duration = datetime.now() - start
@@ -101,7 +101,7 @@ def sharepoint_download(Host, TenantID, ClientID, Secret, SiteName, SharepointF
101101

102102

103103
# ====== Download file using link =====
104-
r = requests.get(ItemID["@microsoft.graph.downloadUrl"], proxies=proxies)
104+
r = requests.get(ItemID["@microsoft.graph.downloadUrl"], proxies=proxies, verify=SSLVerify)
105105

106106
if DownloadMethod == "File":
107107
with open(LocalFilePath, 'wb') as f:

src/dataplane/Microsoft/Sharepoint/sharepoint_upload.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
FileConflict: "fail (default) | replace | rename"
1313
FileDescription: Sharepoint description for the file
1414
"""
15-
def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath, SourceFilePath="/tmp/default.txt", Library="root", UploadMethod="Object", UploadObject="", ProxyUse=False, ProxyUrl="", ProxyMethod="https", FileConflict="fail"):
15+
def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath, SourceFilePath="/tmp/default.txt", Library="root", UploadMethod="Object", UploadObject="", ProxyUse=False, ProxyUrl="", ProxyMethod="https", FileConflict="fail", SSLVerify=True):
1616

1717

1818
import requests
@@ -44,7 +44,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
4444
else:
4545
proxies = {}
4646

47-
auth = requests.request("POST", url, headers=headers, data=payload, proxies=proxies)
47+
auth = requests.request("POST", url, headers=headers, data=payload, proxies=proxies, verify=SSLVerify)
4848

4949
if auth.status_code != 200:
5050
duration = datetime.now() - start
@@ -60,7 +60,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
6060

6161
# ======= Get Site ID from Site name ====
6262
SiteName = SiteName.replace(" ", "")
63-
SiteID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{Host}:/sites/{SiteName}?$select=id", headers=headers, json=payload, proxies=proxies)
63+
SiteID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{Host}:/sites/{SiteName}?$select=id", headers=headers, json=payload, proxies=proxies, verify=SSLVerify)
6464

6565
if SiteID.status_code != 200:
6666
duration = datetime.now() - start
@@ -80,7 +80,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
8080
else:
8181

8282
drive = ""
83-
driveID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{SiteID['id']}/drives?$select=name,id", headers=headers, json=payload, proxies=proxies)
83+
driveID = requests.request("GET", f"https://graph.microsoft.com/v1.0/sites/{SiteID['id']}/drives?$select=name,id", headers=headers, json=payload, proxies=proxies, verify=SSLVerify)
8484
if driveID.status_code != 200:
8585
duration = datetime.now() - start
8686
return {"result":"Fail", "reason":"Sharepoint get drives", "duration": str(duration), "status": driveID.status_code, "error": driveID.json()}
@@ -111,7 +111,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
111111
"fileSize": FileSize,
112112
"name": TargetFilePath
113113
}
114-
UploadUrl = requests.request("POST", url, headers=headers, json=payload, proxies=proxies)
114+
UploadUrl = requests.request("POST", url, headers=headers, json=payload, proxies=proxies, verify=SSLVerify)
115115

116116
if UploadUrl.status_code != 200:
117117
duration = datetime.now() - start
@@ -132,7 +132,7 @@ def sharepoint_upload(Host, TenantID, ClientID, Secret, SiteName, TargetFilePath
132132
# "Authorization": "Bearer " + auth["access_token"]
133133
}
134134

135-
upload = requests.put(UploadUrl["uploadUrl"], data=UploadObject, headers=headers, proxies=proxies)
135+
upload = requests.put(UploadUrl["uploadUrl"], data=UploadObject, headers=headers, proxies=proxies, verify=SSLVerify)
136136
if upload.status_code != 201:
137137
duration = datetime.now() - start
138138
return {"result":"non 201", "reason":"Upload file", "duration": str(duration), "status": upload.status_code, "response": upload.json()}

0 commit comments

Comments
 (0)