Skip to content

[WIP] EPIC: FOUR-32115 Microsoft Graph Integration#8906

Open
sanjacornelius wants to merge 4 commits into
developfrom
epic/FOUR-32115
Open

[WIP] EPIC: FOUR-32115 Microsoft Graph Integration#8906
sanjacornelius wants to merge 4 commits into
developfrom
epic/FOUR-32115

Conversation

@sanjacornelius

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

WIP

ci:connector-send-email:epic/FOUR-32115
ci:deploy

Solution

  • List the changes you've introduced to solve the issue.

How to Test

Describe how to test that this solution works.

Related Tickets & Packages

  • Link to any related FOUR tickets, PRDs, or packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

Introduce MicrosoftGraphTokenProvider to obtain and cache OAuth2 client-credentials tokens from Microsoft Graph. The provider validates required credentials, posts to the tenant token endpoint via Guzzle, throws a RuntimeException on missing creds or HTTP errors (propagating server error messages), and caches the access token for ~50 minutes using a server-specific cache key. Includes unit tests that assert exception behavior for missing credentials and mock Guzzle to verify token request parameters and caching behavior.
Add an optional Guzzle Client dependency to MicrosoftGraphTokenProvider so an HTTP client can be injected for testing. The constructor now accepts ?Client $httpClient and the provider uses $this->httpClient ?? new Client() when posting for tokens. Update the unit test to mock GuzzleHttp\Client (remove overload-based mock and separate-process annotations), import Client, and pass the mocked client into the provider. This enables dependency injection and simpler, more reliable tests.
Replace Mockery-based response mocks in MicrosoftGraphTokenProviderTest with an actual GuzzleHttp\Psr7\Response instance. Simplifies the test by providing a real PSR-7 response (200) with a JSON body and removes the need to mock getBody()/getContents() and getStatusCode(). Added the Response use statement.
Add Microsoft Graph token provider with client credentials flow and unit tests
@processmaker-sonarqube

Copy link
Copy Markdown

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-35f64bfa59.engk8s.processmaker.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants