-
Notifications
You must be signed in to change notification settings - Fork 10
feat(forest mcp server): add the token route #1343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CU-86c6ur5gj |
2 new issues
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
307784d to
5b9bcc6
Compare
5b9bcc6 to
c81a0e5
Compare
| /** | ||
| * Setup superagent mocking to intercept HTTP requests made by forestadmin-client | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you want to mock inside the forestadmin-client ? just mock the forestadmin-client itself, we don't need to test its inside behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make sure the call was properly made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By doing so I'm making sure that even when upgrading the forestadmin-client, nothing is broken 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that seems a bit overengineered for a small improvement... we don't need to test the forestadmin-client behavior in these tests, that's a completely different package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mocking a dependency of a dependency to ensure the first one is doing what it should do isn't a very good pattern, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An integration test must test as much as possible everything, without mock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, but testing an other package doesn't make sense. If we want to actually test everything, we'll do end-to-end tests that mount a real forest agent and look at its responses.
Integration tests should test the whole package, but not its dependencies
| // Handle ESM/CJS interop: the module may be double-wrapped with default exports | ||
| const createForestAdminClient = | ||
| typeof forestAdminClientModule === 'function' | ||
| ? forestAdminClientModule | ||
| : // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| ((forestAdminClientModule as any).default as typeof forestAdminClientModule); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm pretty sure we don't need that, you can import '@forestadmin/forestadmin-client' directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I do need it 😅. try without it, it was my first attempt but because of one of the πackages we use (mcp/sdk if I remember well) all the packages are imported as ESM. It's not the same standard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it a tsconfig issue ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it is not as far as I know 😉
| ); | ||
|
|
||
| const token = jsonwebtoken.sign( | ||
| { ...user, serverToken: forestServerAccessToken }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why repeating the userInfo that already are in the serverToken ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No user is a call to the forest server 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean you can decode the token payload and get the userData from there. You know it is valid because that's the server that issued the token directly
Definition of Done
General
Security