Skip to content

Commit

Permalink
Merge PR #809 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by etobella
  • Loading branch information
OCA-git-bot committed Dec 22, 2023
2 parents 9ab6a90 + f01bde0 commit a878f75
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
3 changes: 1 addition & 2 deletions edi_webservice_oca/models/edi_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class EdiBackend(models.Model):

_inherit = "edi.backend"

webservice_backend_id = fields.Many2one("webservice.backend")
Expand All @@ -22,7 +21,7 @@ def _component_match_attrs(self, exchange_record, key):
res = super()._component_match_attrs(exchange_record, key)
if not self.webservice_backend_id or key not in self._webservice_actions:
return res
res["webservice_protocol"] = self.webservice_backend_id.protocol
res["webservice_protocol"] = self.webservice_backend_id.sudo().protocol
return res

def _component_sort_key(self, component_class):
Expand Down
26 changes: 25 additions & 1 deletion edi_webservice_oca/tests/test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit a878f75

Please sign in to comment.