Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NXPY-238: Fix issue with Self signed certificates (Sourcery refactored) #274

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Oct 12, 2022

Pull Request #273 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch, then run:

git fetch origin sourcery/wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Sourcery AI seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sourcery-ai
Copy link
Contributor Author

sourcery-ai bot commented Oct 12, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.17%.

Quality metrics Before After Change
Complexity 3.99 ⭐ 3.93 ⭐ -0.06 👍
Method Length 63.12 🙂 63.07 🙂 -0.05 👍
Working memory 6.24 🙂 6.20 🙂 -0.04 👍
Quality 72.35% 🙂 72.52% 🙂 0.17% 👍
Other metrics Before After Change
Lines 4879 4795 -84
Changed files Quality Before Quality After Quality Change
nuxeo/client.py 60.30% 🙂 60.68% 🙂 0.38% 👍
nuxeo/comments.py 80.38% ⭐ 80.60% ⭐ 0.22% 👍
nuxeo/documents.py 78.25% ⭐ 79.14% ⭐ 0.89% 👍
nuxeo/models.py 88.93% ⭐ 89.04% ⭐ 0.11% 👍
nuxeo/operations.py 50.78% 🙂 51.06% 🙂 0.28% 👍
nuxeo/uploads.py 66.55% 🙂 66.68% 🙂 0.13% 👍
nuxeo/utils.py 66.10% 🙂 65.90% 🙂 -0.20% 👎
nuxeo/handlers/s3.py 71.91% 🙂 71.92% 🙂 0.01% 👍
tests/constants.py 95.67% ⭐ 95.51% ⭐ -0.16% 👎
tests/test_batchupload.py 58.79% 🙂 58.79% 🙂 0.00%
tests/test_document.py 68.93% 🙂 68.91% 🙂 -0.02% 👎
tests/test_log_response.py 93.50% ⭐ 93.41% ⭐ -0.09% 👎
tests/test_nuxeo.py 81.48% ⭐ 81.47% ⭐ -0.01% 👎
tests/test_repository.py 83.41% ⭐ 83.41% ⭐ 0.00%
tests/manual/many_small_files.py 82.28% ⭐ 82.25% ⭐ -0.03% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
nuxeo/client.py NuxeoClient.request 18 🙂 347 ⛔ 17 ⛔ 25.53% 😞 Try splitting into smaller methods. Extract out complex expressions
nuxeo/operations.py API.execute 12 🙂 253 ⛔ 23 ⛔ 29.83% 😞 Try splitting into smaller methods. Extract out complex expressions
nuxeo/operations.py API.save_to_file 19 😞 202 😞 15 😞 33.20% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tests/test_batchupload.py test_upload_several_callbacks 11 🙂 360 ⛔ 37.01% 😞 Try splitting into smaller methods
tests/test_batchupload.py test_idempotent_requests 11 🙂 346 ⛔ 37.43% 😞 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@gitofanindya gitofanindya force-pushed the wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from b11c650 to a8b56fc Compare October 12, 2022 12:53
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 94ef9d7 to bf31ac0 Compare October 12, 2022 12:55
@gitofanindya gitofanindya force-pushed the wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from a8b56fc to fb418e3 Compare October 12, 2022 13:01
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from bf31ac0 to 015a563 Compare October 12, 2022 13:02
self.url = nuxeo_url + "1.0%20GiB.mov"
self.url = f"{nuxeo_url}1.0%20GiB.mov"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseMov.__init__ refactored with the following changes:

self.url = nuxeo_url + "8.3%20GiB.mxf"
self.url = f"{nuxeo_url}8.3%20GiB.mxf"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseMxf.__init__ refactored with the following changes:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextError.__init__ refactored with the following changes:

self.url = nuxeo_url + "small%20file.txt"
self.url = f"{nuxeo_url}small%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextOk.__init__ refactored with the following changes:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextTooLong.__init__ refactored with the following changes:

Comment on lines -18 to +30
@pytest.mark.parametrize(
"method, params, is_valid",
[
# 'file' type in (Blob, str)
("Document.SetBlob", {"file": Blob()}, True),
("Document.SetBlob", {"file": "test.txt"}, True),
("Document.SetBlob", {"file": 0}, False),
# 'blockInheritance' type == boolean
(
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": False},
True,
),
(
), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": "false"},
False,
),
# 'end' type == str
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True),
("Document.AddPermission", {"permission": "Read", "end": True}, False),
# 'value' type == str
("Document.Fetch", {"value": "test.txt"}, True),
("Document.Fetch", {"value": True}, False),
# 'target' type == list
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True),
("Document.MultiPublish", {"target": 0}, False),
# 'pageNo' type == int
("Audit.Query", {"query": "test", "pageNo": 100}, True),
# 'pageSize' type == int
("Audit.Query", {"query": "test", "pageNo": "test"}, False),
("Document.Query", {"query": "test", "pageSize": 10}, True),
("Document.Query", {"query": "test", "pageSize": "test"}, False),
# 'startPage', 'endPage' type == long
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True),
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False),
# 'info' type == dict
("User.Invite", {"info": {"username": "test"}}, True),
("User.Invite", {"info": 0}, False),
# 'properties' type == dict
(
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), (
"Document.Create",
{"type": "Document", "properties": {"dc:title": "test"}},
True,
),
("Document.Create", {"type": "Document", "properties": 0}, False),
# 'file' type == str
("Blob.Create", {"file": "test.txt"}, True),
("Blob.Create", {"file": 0}, False),
# 'value' type == Sequence
("Document.SetProperty", {"xpath": "test", "value": "test"}, True),
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True),
("Document.SetProperty", {"xpath": "test", "value": 0}, False),
# 'query' type == str
("Document.Query", {"query": "test"}, True),
("Document.Query", {"query": 0}, False),
# 'queryParams' type in [list, str]
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True),
("Document.Query", {"query": "test", "queryParams": "test"}, True),
("Document.Query", {"query": "test", "queryParams": 0}, False),
# 'queryParams' is also optional, None should be accepted
("Document.Query", {"query": "test", "queryParams": None}, True),
# 'validationMethod' type == str
("User.Invite", {"validationMethod": "test"}, True),
("User.Invite", {"validationMethod": 0}, False),
# unknown param
("Document.Query", {"alien": "alien"}, False),
],
)
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_check_params refactored with the following changes:

This removes the following comments ( why? ):

# 'startPage', 'endPage' type == long
# 'value' type == Sequence
# 'query' type == str
# 'properties' type == dict
# 'value' type == str
# 'blockInheritance' type == boolean
# 'pageSize' type == int
# unknown param
# 'queryParams' type in [list, str]
# 'end' type == str
# 'queryParams' is also optional, None should be accepted
# 'target' type == list
# 'validationMethod' type == str
# 'info' type == dict
# 'file' type == str
# 'file' type in (Blob, str)
# 'pageNo' type == int

Comment on lines -284 to +228
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_server_info_bad_response refactored with the following changes:

Comment on lines -315 to +259
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_server_version_bad_response_from_server_info refactored with the following changes:

assert len(aces) in (2, 3)
assert len(aces) in {2, 3}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_fetch_acls refactored with the following changes:

file_out = filename + ".dl"
file_out = f"{filename}.dl"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function download_file refactored with the following changes:

@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Base: 93.98% // Head: 94.07% // Increases project coverage by +0.08% 🎉

Coverage data is based on head (e241573) compared to base (3ef327e).
Patch coverage: 90.47% of modified lines in pull request are covered.

Additional details and impacted files
@@                                                            Coverage Diff                                                            @@
##           wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2     #274      +/-   ##
=========================================================================================================================================
+ Coverage                                                                                                  93.98%   94.07%   +0.08%     
=========================================================================================================================================
  Files                                                                                                         26       26              
  Lines                                                                                                       1763     1754       -9     
=========================================================================================================================================
- Hits                                                                                                        1657     1650       -7     
+ Misses                                                                                                       106      104       -2     
Flag Coverage Δ
unit 94.07% <90.47%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
nuxeo/documents.py 92.51% <50.00%> (-0.11%) ⬇️
nuxeo/client.py 98.40% <100.00%> (-0.02%) ⬇️
nuxeo/comments.py 92.10% <100.00%> (ø)
nuxeo/handlers/s3.py 92.68% <100.00%> (ø)
nuxeo/models.py 93.05% <100.00%> (ø)
nuxeo/operations.py 100.00% <100.00%> (ø)
nuxeo/uploads.py 92.19% <100.00%> (+1.28%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gitofanindya gitofanindya force-pushed the wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from fb418e3 to 52a3226 Compare October 13, 2022 05:35
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 015a563 to 29df423 Compare October 13, 2022 05:36
Comment on lines -112 to +126
"User-Agent": app_name + "/" + version,
"User-Agent": f"{app_name}/{version}",
"Accept": "application/json, */*",
}

self.schemas = kwargs.get("schemas", "*")
self.repository = kwargs.pop("repository", "default")
self._session = requests.sessions.Session()
self._session.hooks["response"] = [log_response]
cookies = kwargs.pop("cookies", None)
if cookies:
if cookies := kwargs.pop("cookies", None):
self._session.cookies = cookies
self._session.stream = True
self.client_kwargs = kwargs

self.ssl_verify_needed = True
if "verify" in kwargs.keys():
if "verify" in kwargs:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient.__init__ refactored with the following changes:

Comment on lines -191 to +193
data.update(params)
data |= params

url = self.api_path + "/search/lang/NXQL/execute"
url = f"{self.api_path}/search/lang/NXQL/execute"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient.query refactored with the following changes:

kwargs.update(self.client_kwargs)
kwargs |= self.client_kwargs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient.request refactored with the following changes:

Comment on lines -425 to +424
error_data.update(response.json())
error_data |= response.json()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient._handle_error refactored with the following changes:

kwargs.update(params)
kwargs |= params
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function API.get refactored with the following changes:

Comment on lines -295 to +291
if y_numbers:
return -1

return 0
return -1 if y_numbers else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function version_compare refactored with the following changes:

Comment on lines -253 to +256
to_upload = set(range(1, self.chunk_count + 1, 1)) - set(
to_upload = set(range(1, self.chunk_count + 1)) - set(
self.blob.uploadedChunkIds
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ChunkUploaderS3._compute_chunks_left refactored with the following changes:

WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 5-5 refactored with the following changes:

operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_digester refactored with the following changes:

Comment on lines -226 to +232
params={"document": WORKSPACE_ROOT + "/Document"},
params={"document": f"{WORKSPACE_ROOT}/Document"},
)

if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_execute refactored with the following changes:

Comment on lines -248 to +247
if SSL_VERIFY is False:
blob = batch.get(0, ssl_verify=False)
else:
blob = batch.get(0)
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_fetch refactored with the following changes:

Comment on lines -428 to +430
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
if SSL_VERIFY is False:
operation.input_obj = batch.get(0, ssl_verify=False)
else:
operation.input_obj = batch.get(0)
operation.execute()
if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_operation refactored with the following changes:

Comment on lines -518 to +509
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_upload refactored with the following changes:

Comment on lines -581 to +572
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_upload_several_callbacks refactored with the following changes:

Comment on lines -76 to +81
input_obj="doc:" + WORKSPACE_ROOT,
input_obj=f"doc:{WORKSPACE_ROOT}",
type="Note",
name=name,
properties=properties,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_document_create_bytes_warning refactored with the following changes:

self.url = nuxeo_url + "8.3%20GiB.mxf"
self.url = f"{nuxeo_url}8.3%20GiB.mxf"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseMxf.__init__ refactored with the following changes:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextError.__init__ refactored with the following changes:

self.url = nuxeo_url + "small%20file.txt"
self.url = f"{nuxeo_url}small%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextOk.__init__ refactored with the following changes:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextTooLong.__init__ refactored with the following changes:

Comment on lines -18 to +30
@pytest.mark.parametrize(
"method, params, is_valid",
[
# 'file' type in (Blob, str)
("Document.SetBlob", {"file": Blob()}, True),
("Document.SetBlob", {"file": "test.txt"}, True),
("Document.SetBlob", {"file": 0}, False),
# 'blockInheritance' type == boolean
(
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": False},
True,
),
(
), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": "false"},
False,
),
# 'end' type == str
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True),
("Document.AddPermission", {"permission": "Read", "end": True}, False),
# 'value' type == str
("Document.Fetch", {"value": "test.txt"}, True),
("Document.Fetch", {"value": True}, False),
# 'target' type == list
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True),
("Document.MultiPublish", {"target": 0}, False),
# 'pageNo' type == int
("Audit.Query", {"query": "test", "pageNo": 100}, True),
# 'pageSize' type == int
("Audit.Query", {"query": "test", "pageNo": "test"}, False),
("Document.Query", {"query": "test", "pageSize": 10}, True),
("Document.Query", {"query": "test", "pageSize": "test"}, False),
# 'startPage', 'endPage' type == long
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True),
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False),
# 'info' type == dict
("User.Invite", {"info": {"username": "test"}}, True),
("User.Invite", {"info": 0}, False),
# 'properties' type == dict
(
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), (
"Document.Create",
{"type": "Document", "properties": {"dc:title": "test"}},
True,
),
("Document.Create", {"type": "Document", "properties": 0}, False),
# 'file' type == str
("Blob.Create", {"file": "test.txt"}, True),
("Blob.Create", {"file": 0}, False),
# 'value' type == Sequence
("Document.SetProperty", {"xpath": "test", "value": "test"}, True),
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True),
("Document.SetProperty", {"xpath": "test", "value": 0}, False),
# 'query' type == str
("Document.Query", {"query": "test"}, True),
("Document.Query", {"query": 0}, False),
# 'queryParams' type in [list, str]
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True),
("Document.Query", {"query": "test", "queryParams": "test"}, True),
("Document.Query", {"query": "test", "queryParams": 0}, False),
# 'queryParams' is also optional, None should be accepted
("Document.Query", {"query": "test", "queryParams": None}, True),
# 'validationMethod' type == str
("User.Invite", {"validationMethod": "test"}, True),
("User.Invite", {"validationMethod": 0}, False),
# unknown param
("Document.Query", {"alien": "alien"}, False),
],
)
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_check_params refactored with the following changes:

This removes the following comments ( why? ):

# 'query' type == str
# 'blockInheritance' type == boolean
# 'info' type == dict
# 'end' type == str
# 'file' type in (Blob, str)
# 'file' type == str
# 'startPage', 'endPage' type == long
# 'queryParams' is also optional, None should be accepted
# 'properties' type == dict
# 'target' type == list
# 'value' type == str
# 'pageNo' type == int
# 'pageSize' type == int
# unknown param
# 'queryParams' type in [list, str]
# 'validationMethod' type == str
# 'value' type == Sequence

Comment on lines -284 to +228
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_server_info_bad_response refactored with the following changes:

Comment on lines -315 to +259
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_server_version_bad_response_from_server_info refactored with the following changes:

assert len(aces) in (2, 3)
assert len(aces) in {2, 3}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_fetch_acls refactored with the following changes:

file_out = filename + ".dl"
file_out = f"{filename}.dl"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function download_file refactored with the following changes:

@gitofanindya gitofanindya force-pushed the wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 52a3226 to 3ef327e Compare October 13, 2022 05:44
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 29df423 to e241573 Compare October 13, 2022 05:45
Comment on lines -112 to +126
"User-Agent": app_name + "/" + version,
"User-Agent": f"{app_name}/{version}",
"Accept": "application/json, */*",
}

self.schemas = kwargs.get("schemas", "*")
self.repository = kwargs.pop("repository", "default")
self._session = requests.sessions.Session()
self._session.hooks["response"] = [log_response]
cookies = kwargs.pop("cookies", None)
if cookies:
if cookies := kwargs.pop("cookies", None):
self._session.cookies = cookies
self._session.stream = True
self.client_kwargs = kwargs

self.ssl_verify_needed = True
if "verify" in kwargs.keys():
if "verify" in kwargs:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient.__init__ refactored with the following changes:

Comment on lines -191 to +193
data.update(params)
data |= params

url = self.api_path + "/search/lang/NXQL/execute"
url = f"{self.api_path}/search/lang/NXQL/execute"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient.query refactored with the following changes:

kwargs.update(self.client_kwargs)
kwargs |= self.client_kwargs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient.request refactored with the following changes:

Comment on lines -425 to +424
error_data.update(response.json())
error_data |= response.json()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NuxeoClient._handle_error refactored with the following changes:

kwargs.update(params)
kwargs |= params
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function API.get refactored with the following changes:

Comment on lines -295 to +291
if y_numbers:
return -1

return 0
return -1 if y_numbers else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function version_compare refactored with the following changes:

Comment on lines -253 to +256
to_upload = set(range(1, self.chunk_count + 1, 1)) - set(
to_upload = set(range(1, self.chunk_count + 1)) - set(
self.blob.uploadedChunkIds
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ChunkUploaderS3._compute_chunks_left refactored with the following changes:

WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 5-5 refactored with the following changes:

operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_digester refactored with the following changes:

Comment on lines -226 to +232
params={"document": WORKSPACE_ROOT + "/Document"},
params={"document": f"{WORKSPACE_ROOT}/Document"},
)

if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_execute refactored with the following changes:

Comment on lines -248 to +247
if SSL_VERIFY is False:
blob = batch.get(0, ssl_verify=False)
else:
blob = batch.get(0)
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_fetch refactored with the following changes:

Comment on lines -428 to +430
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
if SSL_VERIFY is False:
operation.input_obj = batch.get(0, ssl_verify=False)
else:
operation.input_obj = batch.get(0)
operation.execute()
if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_operation refactored with the following changes:

Comment on lines -518 to +509
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_upload refactored with the following changes:

Comment on lines -581 to +572
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_upload_several_callbacks refactored with the following changes:

Comment on lines -76 to +81
input_obj="doc:" + WORKSPACE_ROOT,
input_obj=f"doc:{WORKSPACE_ROOT}",
type="Note",
name=name,
properties=properties,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_document_create_bytes_warning refactored with the following changes:

self.url = nuxeo_url + "8.3%20GiB.mxf"
self.url = f"{nuxeo_url}8.3%20GiB.mxf"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseMxf.__init__ refactored with the following changes:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextError.__init__ refactored with the following changes:

self.url = nuxeo_url + "small%20file.txt"
self.url = f"{nuxeo_url}small%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextOk.__init__ refactored with the following changes:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResponseTextTooLong.__init__ refactored with the following changes:

Comment on lines -18 to +30
@pytest.mark.parametrize(
"method, params, is_valid",
[
# 'file' type in (Blob, str)
("Document.SetBlob", {"file": Blob()}, True),
("Document.SetBlob", {"file": "test.txt"}, True),
("Document.SetBlob", {"file": 0}, False),
# 'blockInheritance' type == boolean
(
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": False},
True,
),
(
), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": "false"},
False,
),
# 'end' type == str
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True),
("Document.AddPermission", {"permission": "Read", "end": True}, False),
# 'value' type == str
("Document.Fetch", {"value": "test.txt"}, True),
("Document.Fetch", {"value": True}, False),
# 'target' type == list
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True),
("Document.MultiPublish", {"target": 0}, False),
# 'pageNo' type == int
("Audit.Query", {"query": "test", "pageNo": 100}, True),
# 'pageSize' type == int
("Audit.Query", {"query": "test", "pageNo": "test"}, False),
("Document.Query", {"query": "test", "pageSize": 10}, True),
("Document.Query", {"query": "test", "pageSize": "test"}, False),
# 'startPage', 'endPage' type == long
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True),
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False),
# 'info' type == dict
("User.Invite", {"info": {"username": "test"}}, True),
("User.Invite", {"info": 0}, False),
# 'properties' type == dict
(
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), (
"Document.Create",
{"type": "Document", "properties": {"dc:title": "test"}},
True,
),
("Document.Create", {"type": "Document", "properties": 0}, False),
# 'file' type == str
("Blob.Create", {"file": "test.txt"}, True),
("Blob.Create", {"file": 0}, False),
# 'value' type == Sequence
("Document.SetProperty", {"xpath": "test", "value": "test"}, True),
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True),
("Document.SetProperty", {"xpath": "test", "value": 0}, False),
# 'query' type == str
("Document.Query", {"query": "test"}, True),
("Document.Query", {"query": 0}, False),
# 'queryParams' type in [list, str]
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True),
("Document.Query", {"query": "test", "queryParams": "test"}, True),
("Document.Query", {"query": "test", "queryParams": 0}, False),
# 'queryParams' is also optional, None should be accepted
("Document.Query", {"query": "test", "queryParams": None}, True),
# 'validationMethod' type == str
("User.Invite", {"validationMethod": "test"}, True),
("User.Invite", {"validationMethod": 0}, False),
# unknown param
("Document.Query", {"alien": "alien"}, False),
],
)
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_check_params refactored with the following changes:

This removes the following comments ( why? ):

# 'properties' type == dict
# 'queryParams' is also optional, None should be accepted
# 'value' type == str
# 'target' type == list
# 'blockInheritance' type == boolean
# 'info' type == dict
# 'file' type == str
# 'queryParams' type in [list, str]
# unknown param
# 'startPage', 'endPage' type == long
# 'end' type == str
# 'file' type in (Blob, str)
# 'value' type == Sequence
# 'query' type == str
# 'validationMethod' type == str
# 'pageNo' type == int
# 'pageSize' type == int

Comment on lines -284 to +228
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_server_info_bad_response refactored with the following changes:

Comment on lines -315 to +259
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_server_version_bad_response_from_server_info refactored with the following changes:

assert len(aces) in (2, 3)
assert len(aces) in {2, 3}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_fetch_acls refactored with the following changes:

file_out = filename + ".dl"
file_out = f"{filename}.dl"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function download_file refactored with the following changes:

@sourcery-ai sourcery-ai bot closed this Oct 14, 2022
@sourcery-ai sourcery-ai bot deleted the sourcery/wip-NXPY-238-Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch October 14, 2022 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant