diff --git a/demos/load-testing/jmeter/test/ResourceOwnerPasswordCredentials_jans.jmx b/demos/load-testing/jmeter/test/ResourceOwnerPasswordCredentials_jans.jmx new file mode 100644 index 00000000000..fd145fa4a77 --- /dev/null +++ b/demos/load-testing/jmeter/test/ResourceOwnerPasswordCredentials_jans.jmx @@ -0,0 +1,966 @@ + + + + + + false + true + + + + host + yuriyz-modern-gnat.gluu.info + = + + + scope + openid profile email user_name + = + + + username + admin + = + + + password + 7IiUu*5/HA8H + = + + + client_id + 37d82f27-39f2-423d-85a0-1449b4378b26 + = + + + client_secret + 559b78b9-94c1-4f47-8cb6-7101a456432b + = + + + client_header + to_override_in_jsr223 + = + + + + + + + + + + + ${host} + + 60000 + 60000 + https + + + HttpClient4 + 6 + + + + continue + + false + 1 + + 1 + 1 + 1479823133000 + 1479823133000 + false + + + true + + + + + + true + false + false + + + + + true + + + + 1 + + 1 + session_state_counter + + false + + + + + + + false + password + = + true + grant_type + + + false + ${username} + = + true + username + + + false + ${password} + = + true + password + + + + + + + + + + /jans-auth/restv1/token + POST + true + false + false + false + HttpClient4 + false + + + + + + + Authorization + ${client_header} + + + Content-Type + application/x-www-form-urlencoded + + + + + + java + + + true + double weight = 0.7d; + +int min = 1; +int max = 1000; + +int minX = 1001; +int maxX = 100000; + +float chance = new Random().nextFloat(); +if (chance <= weight) { + min = minX; + max = maxX; +} + +int userNumber = new Random().nextInt(max - min + 1) + min; +String username = "test_user" + userNumber; + +//log.info("username: " + username); + +vars.put("username", username); + +log.info("username: " + vars.get("username") + ", password: " + vars.get("password")); + + + + + true + + + String credentials = vars.get("client_id") + ":" + vars.get("client_secret"); +String clientHeader = "Basic " + org.apache.commons.codec.binary.Base64.encodeBase64String(credentials.getBytes("UTF-8")); +log.info("Credentials: " + credentials + ", clientHeader: " + clientHeader); +OUT.println("Credentials: " + credentials + ", clientHeader: " + clientHeader); +vars.put("client_header", clientHeader); + java + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + + "access_token" + + Assertion.response_data + false + 2 + + + + + access_token + $.access_token + + + + + id_token + $.id_token + + + + + + + + + false + ${access_token} + = + true + access_token + + + + + + + + + + /jans-auth/restv1/userinfo + POST + true + false + false + false + HttpClient4 + false + + + + + + + Content-Type + application/x-www-form-urlencoded + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + java + + + true + import org.apache.jmeter.protocol.http.control.CookieManager; +import org.apache.jmeter.protocol.http.control.Cookie; +import org.apache.jmeter.testelement.property.JMeterProperty; +import org.apache.jmeter.testelement.property.CollectionProperty; + +CookieManager manager = sampler.getCookieManager(); +CollectionProperty collectionProperty = manager.getCookies(); +log.info("cookie collectionProperty : " + collectionProperty + ", size: " + collectionProperty.size()); + +Object session_state_counter = vars.get("session_state_counter"); +log.info("session_state_counter : " + session_state_counter); + +for (int i = 0; i < collectionProperty.size(); i++) { + JMeterProperty p = collectionProperty.get(i); + + if ("session_state".equals(p.getName())) { + //log.info("session_state : " + p.getObjectValue().getValue() + ", id_token: " + vars.get("id_token")); + props.put("oic.session_state." + session_state_counter, p.getObjectValue().getValue()); + props.put("oic.id_token." + session_state_counter, vars.get("id_token")); + log.info("props session_state : " + props.get("oic.session_state." + session_state_counter)); + log.info("props id_token : " + props.get("oic.id_token." + session_state_counter)); + } +} + + + + + + + + + + 60000 + 60000 + + + + 6 + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + + + + continue + + false + -1 + + 1 + 1 + 1480924764000 + 1480924764000 + false + + 3 + true + + + + + false + + + + 3000 + + + + + + + false + ${id_token} + = + true + id_token_hint + + + + + + + + + + + GET + true + false + true + false + false + + + + + java + + + true + import org.apache.jmeter.protocol.http.control.CookieManager; +import org.apache.jmeter.protocol.http.control.Cookie; + +CookieManager manager = sampler.getCookieManager(); + +for (Map.Entry entry : props.entrySet()) { + if (entry.getKey() instanceof String) { + String key = entry.getKey(); + if (key.startsWith("oic.session_state.")) { + String counter = key.substring("oic.session_state.".length()); + + log.info("PRE end session, counter : " + counter + ", session_state: " + entry.getValue() + ", props.getProperty(): " + props.getProperty("oic.session_state." + counter)); + + Cookie cookie = new Cookie("session_state", entry.getValue(), vars.get("host"), "/", false, 0); + manager.add(cookie); + + Object idToken = props.getProperty("oic.id_token." + counter); + log.info("PRE end session, id_token : " + idToken); + vars.put("id_token", idToken); + + props.remove("oic.session_state." + counter); + props.remove("oic.id_token." + counter); + break; + } + } +} + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + continue + + false + 1 + + 2000 + 5 + 1482159304000 + 1482159304000 + false + + + true + + + + + true + + + + + + Authorization + ${client_header} + + + Content-Type + application/x-www-form-urlencoded + + + + + + java + + + true + String credentials = vars.get("client_id") + ":" + vars.get("client_secret"); +String clientHeader = "Basic " + org.apache.commons.codec.binary.Base64.encodeBase64String(credentials.getBytes("UTF-8")); +log.info("Credentials: " + credentials + ", clientHeader: " + clientHeader); +OUT.println("Credentials: " + credentials + ", clientHeader: " + clientHeader); +vars.put("client_header", clientHeader); + + + + + + + false + client_credentials + = + true + grant_type + + + false + ${client_id} + = + true + client_id + + + false + ${scope} + = + true + scope + + + + + + + + + + /oxauth/restv1/token + POST + true + false + true + false + false + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + + +