-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] edi_webservice_oca: use sudo to get webserivce backend info
queue.job task are running in the context with the user that create the edi exchage record as those user are able to create exchange they should be able to read webservice backend while sending data in order to etablish the connexion to send payloads to the related webserivce. We don't want to give explicit read access using access model record to avoid user to retreives third party service credentials. Co-authored-by: Simone Orsi <[email protected]>
- Loading branch information
Showing
2 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,24 @@ def _setup_records(cls): | |
endpoint: push/here | ||
""" | ||
cls.record.type_id.set_settings(cls.settings1) | ||
cls.a_user = ( | ||
cls.env["res.users"] | ||
.with_context(no_reset_password=True) | ||
.create( | ||
{ | ||
"name": "foo", | ||
"login": "a_user", | ||
"email": "[email protected]", | ||
"groups_id": [ | ||
( | ||
6, | ||
0, | ||
(cls.env.ref("base.group_user")).ids, | ||
) | ||
], | ||
} | ||
) | ||
) | ||
|
||
def test_find_component(self): | ||
component = self.backend._get_component(self.record, "send") | ||
|
@@ -79,9 +97,15 @@ def test_component_params(self): | |
@responses.activate | ||
def test_component_send(self): | ||
self.record.type_id.set_settings(self.settings2) | ||
# Internal user should be able to call the third party webservice | ||
# without read access (no ir.access.model records) | ||
# on `webservice.backend` model which store credentials | ||
record = self.record.with_user(self.a_user) | ||
backend = self.backend.with_user(self.a_user) | ||
|
||
url = "https://foo.test/push/here" | ||
responses.add(responses.POST, url, body="{}") | ||
component = self.backend._get_component(self.record, "send") | ||
component = backend._get_component(record, "send") | ||
result = component.send() | ||
self.assertEqual(result, b"{}") | ||
self.assertEqual( | ||
|