jordimontana82 / fake-xrm-easy

The testing framework for Dynamics CRM and Dynamics 365 which runs on an In-Memory context and deals with mocks or fakes for you
https://dynamicsvalue.com/get-started/overview?source=git
Other
263 stars 182 forks source link

Microsoft SDK Message RetrievePrivilegesRequest returns no privilege in response #614

Closed SarviH closed 3 months ago

SarviH commented 3 months ago

Discussed in https://github.com/jordimontana82/fake-xrm-easy/discussions/613

Originally posted by **SarviH** May 23, 2024 Hello, I have a question about SDK Message **RetrievePrivilegesRequest**, the RolePrivileges in the response is null when I use the fakeService, I'm sure the privilege is associated correctly because using a fetchXML Query I see the result. here is my middleware builder, am I doing something wrong or it could be a bug ? ![MiddlewareBuilder](https://github.com/jordimontana82/fake-xrm-easy/assets/149719901/06bdd4a9-3cba-41da-8a95-0d7c8274f444) Thanks for your help in advance
jordimontana82 commented 3 months ago

Hi @SarviH ,

Thank you for your feedback.

This repo (https://github.com/jordimontana82/fake-xrm-easy) is for v1 of FakeXrmEasy, whereas the sample code you posted is for v2 which has its own repo here:

https://github.com/DynamicsValue/fake-xrm-easy. :)

I see a couple of things in your middleware.

1) The .Add() methods should appear before any Use() methods. 2) Then, the order of the Use*() methods is important. If you are using pipeline simulation then the .UsePipelineSimulation() call should be called before any other. Here's an example: https://dynamicsvalue.github.io/fake-xrm-easy-docs/quickstart/plugins/pipeline/basics/

3) There is no need to call .UseMessages() many times, only once should be enough. 4) You can call .AddFakeMessageExecutors many times, but this is only needed if the FakeMessageExecutors live in different assemblies (dunno if this is the case), otherwise one call is also enough: https://dynamicsvalue.github.io/fake-xrm-easy-docs/quickstart/middleware/

Can you try making these changes and see if that resolves it?

SarviH commented 3 months ago

Hello @jordimontana82 , Thanks for your reply and useful suggestions. Sure I'll check all tomorrow and get back to you.

SarviH commented 3 months ago

Hello @jordimontana82 , I tried some modifications on Middleware here is my code :

RetrievePrivilegeMiddleWareBuilder

but I still have 0 results in privileges, the strange thing is that, the AddPrevilegesRoleRequest is working fine and I see the privilege associated to the user, here is my code :

RetrievePrivilege2

but when I try to use RetrieveUserPrivilegesRequest it returns 0 role privileges, and here is the code :

RetrievePrivilege1

Please let me know if you have any idea about this, thanks in advance :)

SarviH commented 3 months ago

Hello dear @jordimontana82 , finally I found out how to resolve this probleme, actually it's not an issue, just need to manipulate the response of the message which is not out of the box in the mock, simply this solved my problem, I'll share here maybe helps the others :) SolutionForRolePrivilegeFakeXRMEasy We can close the issue. Thanks again