-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-config-api): organization configuration management endpoints (
#790) * feat: support jansOrganization config * feat: jans org endpoint * feat: organization config endpoint * feat: jans org management endpoints * feat: jans orgnanization endpoints * feat: jans organization endpoint wip * feat: jans org functionality * feat: jans org functionality * feat: jans org manintenance endpoints - wip * feat: org endpoint * feat: org endpoints * feat: org management endpoints * feat: jans org endpoint management * feat: jans organization management endpoint
- Loading branch information
Showing
12 changed files
with
238 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...g-api/server/src/main/java/io/jans/configapi/rest/resource/auth/OrganizationResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.configapi.rest.resource.auth; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.github.fge.jsonpatch.JsonPatchException; | ||
|
||
import io.jans.as.persistence.model.GluuOrganization; | ||
import io.jans.configapi.service.auth.OrganizationService; | ||
import io.jans.configapi.core.rest.ProtectedApi; | ||
import io.jans.configapi.service.auth.ConfigurationService; | ||
import io.jans.configapi.util.ApiAccessConstants; | ||
import io.jans.configapi.util.ApiConstants; | ||
import io.jans.configapi.core.util.Jackson; | ||
|
||
import java.io.IOException; | ||
import javax.inject.Inject; | ||
import javax.validation.constraints.NotNull; | ||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
@Path(ApiConstants.ORG) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public class OrganizationResource extends BaseResource { | ||
|
||
@Inject | ||
OrganizationService organizationService; | ||
|
||
@GET | ||
@ProtectedApi(scopes = { ApiAccessConstants.ORG_CONFIG_READ_ACCESS }) | ||
public Response getOrganization() { | ||
return Response.ok(organizationService.getOrganization()).build(); | ||
} | ||
|
||
@PATCH | ||
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON) | ||
@ProtectedApi(scopes = { ApiAccessConstants.ORG_CONFIG_WRITE_ACCESS }) | ||
public Response patchOrganization(@NotNull String pathString) throws JsonPatchException, IOException { | ||
log.trace("Organization patch request - pathString:{} ", pathString); | ||
GluuOrganization organization = organizationService.getOrganization(); | ||
organization = Jackson.applyPatch(pathString, organization); | ||
organizationService.updateOrganization(organization); | ||
return Response.ok(organizationService.getOrganization()).build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
jans-config-api/server/src/test/resources/feature/config/org/org-config.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
Feature: Verify Organization configuration endpoint | ||
|
||
Background: | ||
* def mainUrl = org_configuration_url | ||
|
||
@auth-config-get-error | ||
Scenario: Retrieve Organization configuration without bearer token | ||
Given url mainUrl | ||
When method GET | ||
Then status 401 | ||
And print response | ||
|
||
@auth-config-get | ||
Scenario: Retrieve Organization configuration | ||
Given url mainUrl | ||
And header Authorization = 'Bearer ' + accessToken | ||
When method GET | ||
Then status 200 | ||
And print response | ||
And assert response.length != null | ||
|
||
@auth-config-patch | ||
Scenario: Patch Organization configuration | ||
Given url mainUrl | ||
And header Authorization = 'Bearer ' + accessToken | ||
When method GET | ||
Then status 200 | ||
And print response | ||
And assert response.length != null | ||
Given url mainUrl | ||
And header Authorization = 'Bearer ' + accessToken | ||
And header Content-Type = 'application/json-patch+json' | ||
And header Accept = 'application/json' | ||
And print response.description | ||
#And def request_body = (response.description == null ? "[ {\"op\":\"add\", \"path\": \"/description\", \"value\":null } ]" : "[ {\"op\":\"replace\", \"path\": \"/description\", \"value\":"+response.description+" } ]") | ||
And def request_body = (response.description == null ? "[ {\"op\":\"add\", \"path\": \"/description\", \"value\":null } ]" : "[ {\"op\":\"replace\", \"path\": \"/description\", \"value\":\""+response.description+"\" } ]") | ||
And print request_body | ||
And request request_body | ||
Then print request | ||
When method PATCH | ||
Then status 200 | ||
And print response | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters