Skip to content

Commit

Permalink
#360 - Create stress/load test which should cover all APIs with mocke…
Browse files Browse the repository at this point in the history
…d OP
  • Loading branch information
duttarnab committed Sep 9, 2019
1 parent 80d2401 commit 10da9ca
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.gluu.oxd.mock;

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import org.gluu.oxauth.model.common.GrantType;
import org.gluu.oxd.client.ClientInterface;
Expand All @@ -10,17 +9,13 @@
import org.gluu.oxd.common.params.*;
import org.gluu.oxd.common.response.GetLogoutUriResponse;
import org.gluu.oxd.common.response.RegisterSiteResponse;
import org.gluu.oxd.server.GetTokensByCodeTest;
import org.gluu.oxd.server.RegisterSiteTest;
import org.gluu.oxd.server.Tester;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.net.URLEncoder;
import java.util.UUID;

import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static org.gluu.oxd.server.TestUtils.notEmpty;

/**
Expand All @@ -31,7 +26,7 @@
public class AuthorizationCodeFlowTest {

@Parameters({"host", "opHost", "redirectUrls", "userId", "userSecret"})
@Test(enabled = false)
@Test
public void mockTest(String host, String opHost, String redirectUrls, String userId, String userSecret) {
ClientInterface client = Tester.newClient(host);
//Register client
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.gluu.oxd.mock;

import io.dropwizard.testing.DropwizardTestSupport;
import org.gluu.oxd.mock.guice.MockAppModule;
import org.gluu.oxd.server.OxdServerConfiguration;
import org.gluu.oxd.server.ServerLauncher;
import org.gluu.oxd.server.SetUpTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Parameters;

public class SetUpMockServerTest {

private static final Logger LOG = LoggerFactory.getLogger(org.gluu.oxd.mock.SetUpMockServerTest.class);

public static DropwizardTestSupport<OxdServerConfiguration> SUPPORT = null;


@Parameters({"host", "opHost", "redirectUrls"})
@BeforeSuite
public static void beforeSuite(String host, String opHost, String redirectUrls) {
try {
LOG.debug("Running beforeSuite of Mock server...");
ServerLauncher.setInjector(new MockAppModule());
SetUpTest.beforeSuite(host, opHost, redirectUrls);
LOG.debug("Finished beforeSuite of Mock server!");
} catch (Exception e) {
LOG.error("Failed to start suite of Mock server.", e);
throw new AssertionError("Failed to start suite of Mock server.");
}
}

@AfterSuite
public static void afterSuite() {
try {
LOG.debug("Running afterSuite ...");
SetUpTest.afterSuite();
LOG.debug("HTTP server is successfully stopped.");
} catch (Exception e) {
LOG.error("Failed to stop HTTP server.", e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class UmaFullTest {

@Parameters({"host", "redirectUrls", "opHost", "rsProtect"})
@Test(enabled = false)
@Test
public void mockTest(String host, String redirectUrls, String opHost, String rsProtect) throws Exception {

ClientInterface client = Tester.newClient(host);
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions oxd-server/src/test/java/org/gluu/oxd/server/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
public class Base {

@Parameters({"host", "opHost", "redirectUrls", "isLoadTest"})
@Parameters({"host", "opHost", "redirectUrls"})
@BeforeClass
public static void beforeClass(String host, String opHost, String redirectUrls, boolean isLoadTest) {
SetUpTest.beforeSuite(host, opHost, redirectUrls, isLoadTest);
public static void beforeClass(String host, String opHost, String redirectUrls) {
SetUpTest.beforeSuite(host, opHost, redirectUrls);
}

@AfterClass
Expand Down
7 changes: 2 additions & 5 deletions oxd-server/src/test/java/org/gluu/oxd/server/SetUpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ public class SetUpTest {
public static DropwizardTestSupport<OxdServerConfiguration> SUPPORT = null;


@Parameters({"host", "opHost", "redirectUrls", "isLoadTest"})
@Parameters({"host", "opHost", "redirectUrls"})
@BeforeSuite
public static void beforeSuite(String host, String opHost, String redirectUrls, boolean isLoadTest) {
public static void beforeSuite(String host, String opHost, String redirectUrls) {
try {
LOG.debug("Running beforeSuite ...");
if(isLoadTest) {
ServerLauncher.setInjector(new MockAppModule());
}
ServerLauncher.setSetUpSuite(true);

SUPPORT = new DropwizardTestSupport<OxdServerConfiguration>(OxdServerApplication.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
*/
public class UpdateSiteTest {

@Parameters({"host", "opHost", "redirectUrls", "isLoadTest"})
@Parameters({"host", "opHost", "redirectUrls"})
@BeforeClass
public static void beforeClass(String host, String opHost, String redirectUrls, boolean isLoadTest) {
SetUpTest.beforeSuite(host, opHost, redirectUrls, isLoadTest);
public static void beforeClass(String host, String opHost, String redirectUrls) {
SetUpTest.beforeSuite(host, opHost, redirectUrls);
}

@AfterClass
Expand Down
50 changes: 50 additions & 0 deletions oxd-server/src/test/resources/testng-load.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="oxD Suite" parallel="false">

<parameter name="host" value="http://localhost"/>
<parameter name="opHost" value="https://${test.server.name}"/>
<parameter name="opDiscoveryPath" value=""/>
<parameter name="redirectUrls" value="https://client.example.com/cb/home1 https://client.example.com/cb/home2"/>
<parameter name="paramRedirectUrl" value="https://client.example.com/cb/home2"/>
<parameter name="postLogoutRedirectUrl" value="https://client.example.com/cb/logout"/>
<parameter name="postLogoutRedirectUrls" value="https://client.example.com/cb/logout/page1 https://client.example.com/cb/logout/page2"/>
<parameter name="logoutUrl" value="https://client.example.com/logout"/>
<parameter name="state" value="custom_state_for_testing"/>
<parameter name="userId" value="${auth.user.uid}"/>
<parameter name="userSecret" value="${auth.user.password}"/>
<parameter name="clientId" value="${auth.client.id}"/>
<parameter name="clientSecret" value="${auth.client.secret}"/>
<parameter name="rsProtect"
value="{'resources':[{'path':'/ws/phone','conditions':[{'httpMethods':['GET'],'scopes':['http://photoz.example.com/dev/actions/all','http://photoz.example.com/dev/actions/view'],'ticketScopes':['http://photoz.example.com/dev/actions/view']},{'httpMethods':['PUT', 'POST'],'scopes':['http://photoz.example.com/dev/actions/all','http://photoz.example.com/dev/actions/add'],'ticketScopes':['http://photoz.example.com/dev/actions/add']},{'httpMethods':['DELETE'],'scopes':['http://photoz.example.com/dev/actions/all','http://photoz.example.com/dev/actions/remove'],'ticketScopes':['http://photoz.example.com/dev/actions/remove']}]}]}"/>
<parameter name="rsProtectScopeExpression"
value="{'resources':[{'path':'/ws/phone','conditions':[{'httpMethods':['GET'],'scopes':['http://photoz.example.com/dev/actions/all','http://photoz.example.com/dev/actions/view'],'scope_expression':{'rule':{'and':[{'or':[{'var':0},{'var':1}]},{'var':2}]},'data':['http://photoz.example.com/dev/actions/all','http://photoz.example.com/dev/actions/add','http://photoz.example.com/dev/actions/view']}},{'httpMethods':['PUT','POST'],'scope_expression':{'rule':{'and':[{'or':[{'var':0},{'var':1}]},{'var':2}]},'data':['http://photoz.example.com/dev/actions/all','http://photoz.example.com/dev/actions/add','http://photoz.example.com/dev/actions/view']},'ticketScopes':['http://photoz.example.com/dev/actions/add']},{'httpMethods':['DELETE'],'scopes':['http://photoz.example.com/dev/actions/all','http://photoz.example.com/dev/actions/remove'],'ticketScopes':['http://photoz.example.com/dev/actions/remove']}]}]}"/>
<parameter name="rsProtectScopeExpressionSecond"
value="{'resources':[{'path':'/GetAll','conditions':[{'httpMethods':['GET'],'scopes':['http://photoz.example.com/dev/actions/a1','http://photoz.example.com/dev/actions/a2','http://photoz.example.com/dev/actions/a3'],'ticketScopes':['http://photoz.example.com/dev/actions/a1','http://photoz.example.com/dev/actions/a2','http://photoz.example.com/dev/actions/a3'],'scope_expression':{'rule':{'and':[{'or':[{'var':0},{'var':1}]},{'var':2}]},'data':['http://photoz.example.com/dev/actions/a1','http://photoz.example.com/dev/actions/a2','http://photoz.example.com/dev/actions/a3']}}]}]}"/>
<parameter name="correctScopeExpression"
value="{'rule':{'and':[{'or':[{'var':0},{'var':1}]},{'var':2}]},'data':['http://photoz.example.com/dev/actions/a1','http://photoz.example.com/dev/actions/a2','http://photoz.example.com/dev/actions/a3']}"/>
<parameter name="incorrectScopeExpression"
value="{'rule':{'not':[{'or':[{'var':0},{'var':1}]},{'var':2}]},'data':['http://photoz.example.com/dev/actions/a1','http://photoz.example.com/dev/actions/a2','http://photoz.example.com/dev/actions/a3']}"/>
<parameter name="clientJwksUri" value="${clientJwksUri}"/>
<parameter name="accessTokenSigningAlg" value="${accessTokenSigningAlg}"/>


<!-- main class to set up and tear down suite -->
<test name="SetUp" enabled="true">
<classes>
<class name="org.gluu.oxd.mock.SetUpMockServerTest"/>
</classes>
</test>

<!-- Mock tests-->
<test name="Authorization Code Flow Test" enabled="true">
<classes>
<class name="org.gluu.oxd.mock.AuthorizationCodeFlowTest"/>
</classes>
</test>
<test name="UMA - Mock Full Flow Test" enabled="true">
<classes>
<class name="org.gluu.oxd.mock.UmaFullTest"/>
</classes>
</test>
</suite>
16 changes: 0 additions & 16 deletions oxd-server/src/test/resources/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<parameter name="host" value="http://localhost"/>
<parameter name="opHost" value="https://${test.server.name}"/>
<parameter name="opDiscoveryPath" value=""/>
<parameter name="isLoadTest" value="false"/>
<parameter name="redirectUrls" value="https://client.example.com/cb/home1 https://client.example.com/cb/home2"/>
<parameter name="paramRedirectUrl" value="https://client.example.com/cb/home2"/>
<parameter name="postLogoutRedirectUrl" value="https://client.example.com/cb/logout"/>
Expand All @@ -29,10 +28,6 @@
<parameter name="clientJwksUri" value="${clientJwksUri}"/>
<parameter name="accessTokenSigningAlg" value="${accessTokenSigningAlg}"/>

<!--<listeners>
<listener class-name="org.gluu.oxd.mock.listener.EnableMocksListener"></listener>
</listeners>-->

<!-- main class to set up and tear down suite -->
<test name="SetUp" enabled="true">
<classes>
Expand Down Expand Up @@ -253,15 +248,4 @@
<class name="io.swagger.client.api.UmaGetClaimsGatheringUrlTest"/>
</classes>
</test>
<!-- Mock tests-->
<test name="Authorization Code Flow Test" enabled="true">
<classes>
<class name="org.gluu.oxd.mock.AuthorizationCodeFlowTest"/>
</classes>
</test>
<test name="UMA - Mock Full Flow Test" enabled="true">
<classes>
<class name="org.gluu.oxd.mock.UmaFullTest"/>
</classes>
</test>
</suite>
30 changes: 30 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,34 @@
</pluginManagement>
</build>

<profiles>
<profile>
<id>run-load-tests</id>
<activation>
<property>
<name>benchmark</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>false</skipTests>
<failIfNoTests>false</failIfNoTests>
<trimStackTrace>false</trimStackTrace>
<suiteXmlFiles>
<suiteXmlFile>target/test-classes/testng-load.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

</project>
21 changes: 0 additions & 21 deletions test/test.properties
Original file line number Diff line number Diff line change
@@ -1,21 +0,0 @@
test.server.name=ce-dev5.gluu.org
swd.resource=acct:test_user@ce-dev5.gluu.org

auth.user.uid=test_user
auth.user.password=test_user_password
auth.user.inum=B1F3-AEAE-B798
auth.user.email=test_user@test.org

auth.client.id=FF81-2D39
auth.client.secret=n8d2Vx7cLIHX

uma.user.uid=test_user
uma.user.password=test_user_password
uma.pat.client.id=AB77-1A2B
uma.pat.client.secret=kreFfiq2thys

sector.identifier.id=a55ede29-8f5a-461d-b06e-76caee8d40b5
sector.identifier.id.bad=840ef58d-a7d0-4986-af7b-71ed0089ce61

clientKeyStoreFile=profiles/ce-dev5.gluu.org/client_keystore.jks
clientKeyStoreSecret=secret

0 comments on commit 10da9ca

Please sign in to comment.