use of net.minidev.json.JSONObject in project molgenis by molgenis.
the class RestControllerV2IT method batchDelete.
@Test(dependsOnMethods = { "batchCreate", "batchCreateTypeTest", "batchUpdate" }, priority = 10)
public void batchDelete() {
JSONObject jsonObject = new JSONObject();
JSONArray entityIds = new JSONArray();
entityIds.add("55");
entityIds.add("57");
jsonObject.put("entityIds", entityIds);
given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).contentType(APPLICATION_JSON).body(jsonObject.toJSONString()).when().delete(API_V2 + "it_emx_datatypes_TypeTestv2").then().statusCode(NO_CONTENT).log().all();
}
use of net.minidev.json.JSONObject in project molgenis by molgenis.
the class RestControllerV2IT method batchCreateLocation.
@Test
public void batchCreateLocation() {
JSONObject jsonObject = new JSONObject();
JSONArray entities = new JSONArray();
JSONObject entity = new JSONObject();
entity.put("Chromosome", "42");
entity.put("Position", 42);
entities.add(entity);
jsonObject.put("entities", entities);
String expectedLocation = "/api/v2/it_emx_datatypes_Locationv2?q=Position=in=(\"42\")";
String expectedHref = "/api/v2/it_emx_datatypes_Locationv2/42";
given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).contentType(APPLICATION_JSON).body(jsonObject.toJSONString()).when().post(API_V2 + "it_emx_datatypes_Locationv2").then().statusCode(RestTestUtils.CREATED).log().all().body("location", Matchers.equalTo(expectedLocation), "resources[0].href", Matchers.equalTo(expectedHref));
}
use of net.minidev.json.JSONObject in project molgenis by molgenis.
the class RestTestUtils method addToAllUsersGroup.
private static void addToAllUsersGroup(String adminToken, String userName) {
JSONObject groupMembership = new JSONObject();
groupMembership.put(USER, getUserId(adminToken, userName));
groupMembership.put(GroupMemberMetaData.GROUP, getEntityId(adminToken, GroupMetaData.NAME, ALL_USER_GROUP, GroupMetaData.GROUP));
given().header(X_MOLGENIS_TOKEN, adminToken).contentType(APPLICATION_JSON).body(groupMembership.toJSONString()).when().post("api/v1/" + GROUP_MEMBER);
}
use of net.minidev.json.JSONObject in project molgenis by molgenis.
the class RestTestUtils method createUser.
/**
* Create a user with userName and password as admin using given token.
*
* @param adminToken the token to use for login
* @param userName the name of the user to create
* @param password the password of the user to create
*/
public static void createUser(String adminToken, String userName, String password) {
if (adminToken != null) {
JSONObject createTestUserBody = new JSONObject();
createTestUserBody.put("active", true);
createTestUserBody.put("username", userName);
createTestUserBody.put("password_", password);
createTestUserBody.put("superuser", false);
createTestUserBody.put("changePassword", false);
createTestUserBody.put("Email", userName + "@example.com");
given().header(X_MOLGENIS_TOKEN, adminToken).contentType(APPLICATION_JSON).body(createTestUserBody.toJSONString()).when().post("api/v1/sys_sec_User");
addToAllUsersGroup(adminToken, userName);
}
}
use of net.minidev.json.JSONObject in project spring-security by spring-projects.
the class OAuth2ResourceServerBeanDefinitionParserTests method jwtFromIssuer.
private String jwtFromIssuer(String issuer) throws Exception {
Map<String, Object> claims = new HashMap<>();
claims.put(JwtClaimNames.ISS, issuer);
claims.put(JwtClaimNames.SUB, "test-subject");
claims.put("scope", "message:read");
JWSObject jws = new JWSObject(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID("1").build(), new Payload(new JSONObject(claims)));
jws.sign(new RSASSASigner(TestKeys.DEFAULT_PRIVATE_KEY));
return jws.serialize();
}
Aggregations