Skip to content

Fix Microsoft Graph filter rendering for Boolean and null values, improves guest invitation creation logic, updates the Maven build for Java 17 and the current connector parent, fix the TestNG/Surefire setup so unit and integration tests run reliably.#45

Open
lubomarton wants to merge 1 commit into
masterfrom
feature/msgraph-filter-guest-test-fixes

Conversation

@lubomarton

Copy link
Copy Markdown

Summary

This PR fixes Microsoft Graph filter rendering for Boolean and null values, improves guest invitation creation logic, updates the Maven build for Java 17 and the current connector parent, and fixes the TestNG/Surefire setup so unit and integration tests run reliably.

Filter

The connector now renders OData Boolean and null literals instead of wrapping them as strings.

Examples:

  • accountEnabled = true -> accountEnabled eq true
  • onPremisesSyncEnabled = false -> onPremisesSyncEnabled eq false
  • onPremisesSyncEnabled = null -> onPremisesSyncEnabled eq null

Null equality also enables $count=true, which is required for Microsoft Graph advanced directory queries.

Guest invitation

Guest invitation creation is now selected explicitly by:

  • inviteGuests = true
  • mail is present
  • userType = Guest

The connector no longer relies on comparing the mail domain with tenantId.

The invitation path now rejects invalid guest-create input:

  • userPrincipalName must not be provided for invitation-based guest creation.
  • Password must not be provided for invitation-based guest creation.

This avoids accidentally creating a normal user or sending invalid invitation payloads.

Invitation message payload

UserProcessing.buildInvitation() now creates invitedUserMessageInfo according to the Microsoft Graph schema.

Previously, the configured invitation message was sent directly as a string:

{
  "invitedUserMessageInfo": "Welcome message"
}

Microsoft Graph requires invitedUserMessageInfo to be an object. The connector now sends:

{
    "invitedUserMessageInfo": {
      "customizedMessageBody": "Welcome message"
    }
}

The invitedUserMessageInfo property is omitted when the configured invitation message is empty or blank. This allows Microsoft Graph to use its default invitation message.

The invitation payload continues to include:

invitedUserEmailAddress
invitedUserDisplayName when available
invitedUserType
inviteRedirectUrl
sendInvitationMessage

Reference: Microsoft Graph invitedUserMessageInfo resource documentation:
https://learn.microsoft.com/en-us/graph/api/resources/invitedusermessageinfo?view=graph-rest-1.0

Test infrastructure

This PR also fixes and improves tests:

  • Uses Java 17 compiler release configuration.
  • Uses TestNG Surefire provider explicitly.
  • Keeps unit as the default test group.
  • Fixes MockGraphEndpoint initialization so unit tests do not fail on null configuration.
  • Fixes SchemaTranslatorFilterTest to use a mock endpoint-backed schema translator.
  • Replaces the remaining JUnit Assert import in ListAllTest with TestNG Assert.

Added test coverage

Unit tests:

  • Boolean filter literal rendering
  • Null filter literal rendering
  • String escaping in filters
  • Guest invitation positive path
  • Guest invitation validation for forbidden UPN
  • Guest invitation validation for forbidden password
  • Guest invitation custom message wrapped in invitedUserMessageInfo.customizedMessageBody
  • Empty invitation message omits invitedUserMessageInfo

Integration tests:

  • Search by accountEnabled = true
  • Search by accountEnabled = false
  • Search by onPremisesSyncEnabled = null
  • Search by string "null" mapped to OData null literal

Notes

Integration tests require a real Microsoft Entra test tenant and valid application credentials in local test properties. They create and delete test users, so they should not be run against a production tenant.

Testing

Unit tests:

mvn clean install

Integration tests:

mvn  -Dtest=FilteringTest -Dgroups=integration test

Targeted invitation unit tests:

mvn -Dtest=UserProcessingTest#testCreateGuestUsesInvitationWhenUpnAndPasswordAreMissing+testCreateGuestInvitationRejectsUserPrincipalName+testCreateGuestInvitationRejectsPassword -Dgroups=unit test

Build and dependency updates

This PR also updates the Maven build configuration to align the connector with the current connector parent and Java baseline.

POM changes include:

  • Updates connector-parent to 1.5.2.0.
  • Sets the compiler configuration to Java 17 using:
    <release>17</release>

Keeps unit as the default TestNG group via:

    <groups>unit</groups>

Adds an explicit Surefire version property:

    <surefire.version>3.2.5</surefire.version>

Forces Maven Surefire to use the TestNG provider by adding surefire-testng as a plugin dependency.
This prevents Surefire from auto-detecting the JUnit Platform provider and silently running zero TestNG tests.

Dependency updates include:

  • org.json:json updated to 20250517.
  • commons-codec:commons-codec updated to 1.18.0.
  • commons-io:commons-io updated to 2.18.0 for test scope.
  • org.slf4j:slf4j-simple updated to 1.7.36.

Dependency management updates include:

  • org.bouncycastle:bcprov-jdk15on pinned to 1.70.
  • com.nimbusds:nimbus-jose-jwt pinned to 10.0.2.
  • net.minidev:json-smart pinned to 2.5.2.
  • com.google.code.gson:gson pinned to 2.13.1.
  • org.apache.commons:commons-lang3 pinned to 3.18.0.
  • org.yaml:snakeyaml pinned to 2.4.

improves guest invitation creation logic,
updates the Maven build for Java 17 and the current connector parent,
fix the TestNG/Surefire setup so unit and integration tests run reliably.
@lubomarton
lubomarton requested a review from matusmacik July 15, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants