Skip to content

Commit 7b86595

Browse files
Add some code coverage for SPO connector to be able to backport/merge stuff again (#3795)
Subj. (cherry picked from commit 530e7c0) # Conflicts: # NOTICE.txt
1 parent 5ecc372 commit 7b86595

File tree

2 files changed

+102
-35
lines changed

2 files changed

+102
-35
lines changed

NOTICE.txt

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333

3434
MarkupSafe
3535
3.0.3
36-
UNKNOWN
36+
BSD-3-Clause
3737
Copyright 2010 Pallets
3838

3939
Redistribution and use in source and binary forms, with or without
@@ -91,8 +91,8 @@ SOFTWARE.
9191

9292

9393
PyMySQL
94-
1.1.1
95-
MIT License
94+
1.1.2
95+
MIT
9696
Copyright (c) 2010, 2013 PyMySQL contributors
9797

9898
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1603,7 +1603,7 @@ Apache License
16031603

16041604
anyio
16051605
4.11.0
1606-
UNKNOWN
1606+
MIT
16071607
The MIT License (MIT)
16081608

16091609
Copyright (c) 2018 Alex Grönholm
@@ -1854,8 +1854,8 @@ Copyright (C) 2016-present the asyncpg authors and contributors.
18541854

18551855

18561856
attrs
1857-
25.3.0
1858-
UNKNOWN
1857+
25.4.0
1858+
MIT
18591859
The MIT License (MIT)
18601860

18611861
Copyright (c) 2015 Hynek Schlawack and the attrs contributors
@@ -1880,7 +1880,7 @@ SOFTWARE.
18801880

18811881

18821882
azure-core
1883-
1.35.1
1883+
1.36.0
18841884
MIT License
18851885
Copyright (c) Microsoft Corporation.
18861886

@@ -2164,7 +2164,7 @@ Apache Software License
21642164

21652165
beautifulsoup4
21662166
4.12.2
2167-
MIT License
2167+
MIT
21682168
Beautiful Soup is made available under the MIT license:
21692169

21702170
Copyright (c) Leonard Richardson
@@ -2564,7 +2564,7 @@ Apache Software License
25642564

25652565
bracex
25662566
2.6
2567-
MIT License
2567+
MIT
25682568
MIT License
25692569

25702570
Copyright (c) 2018 - 2025 Isaac Muse
@@ -2606,7 +2606,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26062606

26072607

26082608
cachetools
2609-
6.2.0
2609+
6.2.1
26102610
MIT License
26112611
The MIT License (MIT)
26122612

@@ -2687,7 +2687,7 @@ documentation is licensed as follows:
26872687

26882688

26892689
charset-normalizer
2690-
3.4.3
2690+
3.4.4
26912691
MIT
26922692
MIT License
26932693

@@ -3341,7 +3341,7 @@ SOFTWARE
33413341

33423342
elasticsearch
33433343
8.17.1
3344-
Apache Software License
3344+
Apache-2.0
33453345

33463346
Apache License
33473347
Version 2.0, January 2004
@@ -3521,7 +3521,7 @@ Apache Software License
35213521

35223522

35233523
elasticsearch-connectors
3524-
8.18.7
3524+
8.18.9
35253525
Apache Software License
35263526
Elastic License 2.0
35273527

@@ -4384,7 +4384,7 @@ THE SOFTWARE.
43844384

43854385

43864386
grpcio
4387-
1.73.0
4387+
1.75.1
43884388
Apache Software License
43894389

43904390
Apache License
@@ -4999,7 +4999,7 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
49994999

50005000

50015001
grpcio-tools
5002-
1.71.0
5002+
1.71.2
50035003
Apache Software License
50045004
UNKNOWN
50055005

@@ -5032,7 +5032,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50325032

50335033
httpcore
50345034
1.0.9
5035-
BSD License
5035+
BSD-3-Clause
50365036
Copyright © 2020, [Encode OSS Ltd](https://www.encode.io/).
50375037
All rights reserved.
50385038

@@ -5064,7 +5064,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50645064

50655065
httpx
50665066
0.27.0
5067-
BSD License
5067+
BSD-3-Clause
50685068
Copyright © 2019, [Encode OSS Ltd](https://www.encode.io/).
50695069
All rights reserved.
50705070

@@ -5100,11 +5100,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
51005100

51015101

51025102
idna
5103-
3.10
5104-
BSD License
5103+
3.11
5104+
BSD-3-Clause
51055105
BSD 3-Clause License
51065106

5107-
Copyright (c) 2013-2024, Kim Davies and contributors.
5107+
Copyright (c) 2013-2025, Kim Davies and contributors.
51085108
All rights reserved.
51095109

51105110
Redistribution and use in source and binary forms, with or without
@@ -5655,8 +5655,8 @@ MIT License
56555655

56565656

56575657
multidict
5658-
6.5.0
5659-
Apache Software License
5658+
6.7.0
5659+
Apache License 2.0
56605660
Copyright 2016 Andrew Svetlov and aio-libs contributors
56615661

56625662
Licensed under the Apache License, Version 2.0 (the "License");
@@ -5977,7 +5977,7 @@ BSD
59775977
UNKNOWN
59785978

59795979
propcache
5980-
0.4.0
5980+
0.4.1
59815981
Apache Software License
59825982

59835983
Apache License
@@ -6725,7 +6725,7 @@ Apache Software License
67256725

67266726
pyspnego
67276727
0.12.0
6728-
UNKNOWN
6728+
MIT
67296729
MIT License
67306730

67316731
Copyright (c) 2020 Jordan Borean, Red Hat
@@ -7433,7 +7433,7 @@ made under the terms of *both* these licenses.
74337433

74347434
soupsieve
74357435
2.8
7436-
MIT License
7436+
MIT
74377437
MIT License
74387438

74397439
Copyright (c) 2018 - 2025 Isaac Muse <[email protected]>
@@ -7543,8 +7543,8 @@ Apache Software License
75437543
UNKNOWN
75447544

75457545
typing_extensions
7546-
4.14.1
7547-
UNKNOWN
7546+
4.15.0
7547+
PSF-2.0
75487548
A. HISTORY OF THE SOFTWARE
75497549
==========================
75507550

@@ -7885,7 +7885,7 @@ made under the terms of *both* these licenses.
78857885

78867886
urllib3
78877887
2.5.0
7888-
UNKNOWN
7888+
MIT
78897889
MIT License
78907890

78917891
Copyright (c) 2008-2020 Andrey Petrov and contributors.
@@ -8144,7 +8144,7 @@ SOFTWARE.
81448144

81458145

81468146
wrapt
8147-
1.17.2
8147+
1.17.3
81488148
BSD License
81498149
Copyright (c) 2013-2023, Graham Dumpleton
81508150
All rights reserved.
@@ -8173,7 +8173,7 @@ POSSIBILITY OF SUCH DAMAGE.
81738173

81748174

81758175
xmltodict
8176-
1.0.0
8176+
1.0.2
81778177
MIT License
81788178
Copyright (C) 2012 Martin Blech and individual contributors.
81798179

@@ -8185,7 +8185,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
81858185

81868186

81878187
yarl
8188-
1.21.0
8188+
1.22.0
81898189
Apache Software License
81908190

81918191
Apache License

tests/sources/test_sharepoint_online.py

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
_prefix_user,
5050
_prefix_user_id,
5151
)
52-
from connectors.utils import iso_utc
52+
from connectors.utils import ISO_ZULU_TIMESTAMP_FORMAT, iso_utc
5353
from tests.commons import AsyncIterator
5454
from tests.sources.support import create_source
5555

@@ -234,6 +234,8 @@ async def create_spo_source(
234234
tenant_name="test",
235235
client_id="2",
236236
secret_value="3",
237+
certificate=None,
238+
private_key=None,
237239
auth_method="secret",
238240
site_collections=WILDCARD,
239241
use_document_level_security=False,
@@ -248,6 +250,8 @@ async def create_spo_source(
248250
tenant_id=tenant_id,
249251
client_id=client_id,
250252
secret_value=secret_value,
253+
certificate=certificate,
254+
private_key=private_key,
251255
tenant_name=tenant_name,
252256
site_collections=site_collections,
253257
use_document_level_security=use_document_level_security,
@@ -2991,16 +2995,64 @@ async def test_download_function_with_filtering_rule(self):
29912995
async with create_spo_source() as source:
29922996
max_drive_item_age = 15
29932997
drive_item = {
2994-
"name": "test",
2995-
"lastModifiedDateTime": str(
2998+
"name": "test.txt",
2999+
"@microsoft.graph.downloadUrl": "http://localhost/filename",
3000+
"lastModifiedDateTime": (
29963001
datetime.utcnow() - timedelta(days=max_drive_item_age + 1)
2997-
),
3002+
).strftime(ISO_ZULU_TIMESTAMP_FORMAT),
3003+
}
3004+
3005+
download_result = source.download_function(drive_item, max_drive_item_age)
3006+
3007+
assert download_result is None
3008+
3009+
@pytest.mark.asyncio
3010+
async def test_download_function_for_file_with_no_lastModifiedDatetTime(self):
3011+
async with create_spo_source() as source:
3012+
max_drive_item_age = 15
3013+
drive_item = {
3014+
"name": "test.txt",
3015+
"@microsoft.graph.downloadUrl": "http://localhost/filename",
29983016
}
29993017

30003018
download_result = source.download_function(drive_item, max_drive_item_age)
30013019

30023020
assert download_result is None
30033021

3022+
@pytest.mark.asyncio
3023+
async def test_download_function_for_too_large_file(self):
3024+
async with create_spo_source() as source:
3025+
max_drive_item_age = 15
3026+
drive_item = {
3027+
"name": "test.txt",
3028+
"@microsoft.graph.downloadUrl": "http://localhost/filename",
3029+
"size": 5 * 1024 * 1024 * 1024,
3030+
"lastModifiedDateTime": (
3031+
datetime.now(timezone.utc) - timedelta(days=max_drive_item_age - 5)
3032+
).strftime(ISO_ZULU_TIMESTAMP_FORMAT),
3033+
}
3034+
3035+
download_result = source.download_function(drive_item, max_drive_item_age)
3036+
3037+
assert download_result is None
3038+
3039+
@pytest.mark.asyncio
3040+
async def test_download_function_for_recently_changed_file(self):
3041+
async with create_spo_source() as source:
3042+
max_drive_item_age = 15
3043+
drive_item = {
3044+
"name": "test.txt",
3045+
"@microsoft.graph.downloadUrl": "http://localhost/filename",
3046+
"size": 5000,
3047+
"lastModifiedDateTime": (
3048+
datetime.now(timezone.utc) - timedelta(days=max_drive_item_age - 5)
3049+
).strftime(ISO_ZULU_TIMESTAMP_FORMAT),
3050+
}
3051+
3052+
download_result = source.download_function(drive_item, max_drive_item_age)
3053+
3054+
assert download_result is not None
3055+
30043056
def test_get_default_configuration(self):
30053057
config = SharepointOnlineDataSource.get_default_configuration()
30063058

@@ -3053,6 +3105,21 @@ async def test_validate_config(self, patch_sharepoint_client):
30533105
patch_sharepoint_client.rest_api_token.get.assert_awaited()
30543106
patch_sharepoint_client.site_collections.assert_not_called()
30553107

3108+
@pytest.mark.asyncio
3109+
async def test_correct_tokens_are_set_when_certificates_are_used(self):
3110+
private_key = "opens_all_locks"
3111+
certificate = "its_certified"
3112+
async with create_spo_source(
3113+
auth_method="certificate",
3114+
secret_value=None,
3115+
private_key=private_key,
3116+
certificate=certificate,
3117+
) as source:
3118+
client = source.client
3119+
3120+
assert isinstance(client.graph_api_token, EntraAPIToken)
3121+
assert isinstance(client.rest_api_token, EntraAPIToken)
3122+
30563123
@pytest.mark.asyncio
30573124
async def test_validate_config_when_invalid_tenant(self, patch_sharepoint_client):
30583125
invalid_tenant_name = "wat"

0 commit comments

Comments
 (0)