Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.InputStream;
import java.time.Instant;
import java.util.List;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Stream;

Expand Down Expand Up @@ -223,7 +224,8 @@ public Response patch(@PathParam("id") String id, PatchRequest request) {
return resourceNotFound(id);
}

if (!request.getSchemas().contains(Scim.PATCH_OP_CORE_SCHEMA)) {
Set<String> schemas = request.getSchemas();
if (schemas == null || !schemas.contains(Scim.PATCH_OP_CORE_SCHEMA)) {
return invalidSyntax("No PATCH op schema provided in request");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,27 @@ public void testPatchAdd() {
assertEquals("Amanda", actual.getFirstName());
}

@Test
public void testPatchWithNullSchemas() {
User expected = client.users().create(createUser());

// a PATCH request body carrying "schemas": null deserializes the schemas set to null,
// which must yield a 400 invalidSyntax response rather than a NullPointerException
PatchRequest request = PatchRequest.create()
.add("active", "false")
.build();
request.setSchemas(null);

try {
client.users().patch(expected.getId(), request);
fail("should fail because the PATCH op schema is missing");
} catch (ScimClientException sce) {
ErrorResponse error = sce.getError();
assertNotNull(error);
assertEquals(400, error.getStatusInt());
}
}

@Test
public void testPatchReplace() {
User expected = client.users().create(createUser());
Expand Down