herbsjs / buchu

Use Cases - Uniform, auditable and secure use case library
Other
24 stars 22 forks source link

authorize in UseCase class was not been called #81

Closed vitorgamer58 closed 2 years ago

vitorgamer58 commented 2 years ago

Describe the bug In my UseCase I defined the following authorization code: authorize: () => Ok(true), But the usecase returned with a error: Err { _error: 'Not Authorized' } Which doesn't make any logical sense, since my authorization doesn't return an error, and it should always return Ok()

To Reproduce Steps to reproduce the behavior:

Create a UseCase and put a normal Authorize, and then request through the Rest API the endpoint that calls this UseCase. A curiosity about this bug is that it only happens through the Rest API call, and does not happen in unit tests.

Expected behavior The expected behavior is that it should go through the authorize de and proceed with the usecase steps, which didn't happen in my case.

Screenshots Screenshot_6852

Additional context I'm using the latest version of Herbsjs, I can provide the code in zip with the error happening.

vitorgamer58 commented 2 years ago

Locally, adding this line in the function run of the UseCase class made my code work, but when doing this in the repository and running the buchu tests, many of tests failed. Screenshot_6853

vitorgamer58 commented 2 years ago

Solved, It's my fault. Need to call await useCaseName.authorize(); Before than await useCaseName.run()