-
-
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.
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 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
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,20 @@ def _setup_records(cls): | |
endpoint: push/here | ||
""" | ||
cls.record.type_id.set_settings(cls.settings1) | ||
cls.a_user = cls.env["res.users"].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") | ||
|
@@ -88,3 +102,20 @@ def test_component_send(self): | |
responses.calls[0].request.headers["Content-Type"], "application/xml" | ||
) | ||
self.assertEqual(responses.calls[0].request.body, "This is a simple file") | ||
|
||
@responses.activate | ||
def test_compenent_send_by_end_user(self): | ||
|
||
self.record.type_id.set_settings(self.settings2) | ||
self.record = self.record.with_user(self.a_user) | ||
self.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") | ||
result = component.send() | ||
self.assertEqual(result, b"{}") | ||
self.assertEqual( | ||
responses.calls[0].request.headers["Content-Type"], "application/xml" | ||
) | ||
self.assertEqual(responses.calls[0].request.body, "This is a simple file") |