-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#360 - Create stress/load test which should cover all APIs with mocke…
…d OP
- Loading branch information
Showing
13 changed files
with
341 additions
and
14 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
15 changes: 15 additions & 0 deletions
15
oxd-server/src/main/java/org/gluu/oxd/server/op/OpClientFactory.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,15 @@ | ||
package org.gluu.oxd.server.op; | ||
|
||
import org.gluu.oxauth.client.*; | ||
|
||
public interface OpClientFactory { | ||
public TokenClient createTokenClient(String url); | ||
|
||
public UserInfoClient createUserInfoClient(String url); | ||
|
||
public RegisterClient createRegisterClient(String url); | ||
|
||
public OpenIdConfigurationClient createOpenIdConfigurationClient(String url); | ||
|
||
public AuthorizeClient createAuthorizeClient(String url); | ||
} |
30 changes: 30 additions & 0 deletions
30
oxd-server/src/main/java/org/gluu/oxd/server/op/OpClientFactoryImpl.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,30 @@ | ||
package org.gluu.oxd.server.op; | ||
|
||
import org.gluu.oxauth.client.*; | ||
|
||
public class OpClientFactoryImpl implements OpClientFactory { | ||
|
||
public OpClientFactoryImpl() { | ||
} | ||
|
||
public TokenClient createTokenClient(String url) { | ||
return new TokenClient(url); | ||
} | ||
|
||
public UserInfoClient createUserInfoClient(String url) { | ||
return new UserInfoClient(url); | ||
} | ||
|
||
public RegisterClient createRegisterClient(String url) { | ||
return new RegisterClient(url); | ||
} | ||
|
||
public OpenIdConfigurationClient createOpenIdConfigurationClient(String url) { | ||
return new OpenIdConfigurationClient(url); | ||
} | ||
|
||
public AuthorizeClient createAuthorizeClient(String url) { | ||
return new AuthorizeClient(url); | ||
} | ||
|
||
} |
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
105 changes: 105 additions & 0 deletions
105
oxd-server/src/test/java/org/gluu/oxd/server/mock/op/MockSetUpTest.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,105 @@ | ||
package org.gluu.oxd.server.mock.op; | ||
|
||
import com.google.common.base.Preconditions; | ||
import io.dropwizard.testing.ConfigOverride; | ||
import io.dropwizard.testing.DropwizardTestSupport; | ||
import io.dropwizard.testing.ResourceHelpers; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.gluu.oxd.common.response.RegisterSiteResponse; | ||
import org.gluu.oxd.server.*; | ||
import org.gluu.oxd.server.persistence.PersistenceService; | ||
import org.gluu.oxd.server.service.RpService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.testng.annotations.AfterSuite; | ||
import org.testng.annotations.BeforeSuite; | ||
import org.testng.annotations.Parameters; | ||
|
||
/** | ||
* Main class to set up and tear down suite. | ||
* | ||
* @author Yuriy Zabrovarnyy | ||
* @version 0.9, 21/08/2013 | ||
*/ | ||
|
||
public class MockSetUpTest { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(SetUpTest.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 ..."); | ||
ServerLauncher.setSetUpSuite(true); | ||
|
||
SUPPORT = new DropwizardTestSupport<OxdServerConfiguration>(OxdServerApplication.class, | ||
ResourceHelpers.resourceFilePath("oxd-server-jenkins.yml"), | ||
ConfigOverride.config("server.applicationConnectors[0].port", "0") // Optional, if not using a separate testing-specific configuration file, use a randomly selected port | ||
); | ||
SUPPORT.before(); | ||
LOG.debug("HTTP server started."); | ||
|
||
setOpClientFactory(); | ||
LOG.debug("HTTP server started."); | ||
|
||
removeExistingRps(); | ||
LOG.debug("Existing RPs are removed."); | ||
|
||
RegisterSiteResponse setupClient = SetupClientTest.setupClient(MockTester.newClient(host), opHost, redirectUrls); | ||
MockTester.setSetupClient(setupClient, host, opHost); | ||
LOG.debug("SETUP_CLIENT is set in Tester."); | ||
|
||
Preconditions.checkNotNull(MockTester.getAuthorization()); | ||
LOG.debug("Tester's authorization is set."); | ||
|
||
setupSwaggerSuite(MockTester.getTargetHost(host), opHost, redirectUrls); | ||
LOG.debug("Finished beforeSuite!"); | ||
} catch (Exception e) { | ||
LOG.error("Failed to start suite.", e); | ||
throw new AssertionError("Failed to start suite."); | ||
} | ||
} | ||
|
||
private static void setOpClientFactory() { | ||
ServerLauncher.getInjector().getInstance(RestResource.class).setOpClientFactory(new OpClientFactoryStubImpl()); | ||
} | ||
private static void setupSwaggerSuite(String host, String opHost, String redirectUrls) { | ||
try { | ||
if (StringUtils.countMatches(host, ":") < 2 && "http://localhost".equalsIgnoreCase(host) || "http://127.0.0.1".equalsIgnoreCase(host) ) { | ||
host = host + ":" + SetUpTest.SUPPORT.getLocalPort(); | ||
} | ||
io.swagger.client.api.SetUpTest.beforeSuite(host, opHost, redirectUrls); // manual swagger tests setup | ||
io.swagger.client.api.SetUpTest.setTokenProtectionEnabled(SUPPORT.getConfiguration().getProtectCommandsWithAccessToken()); | ||
} catch (Throwable e) { | ||
LOG.error("Failed to setup swagger suite."); | ||
} | ||
} | ||
|
||
private static void removeExistingRps() { | ||
try { | ||
ServerLauncher.getInjector().getInstance(PersistenceService.class).create(); | ||
ServerLauncher.getInjector().getInstance(RpService.class).removeAllRps(); | ||
ServerLauncher.getInjector().getInstance(RpService.class).load(); | ||
LOG.debug("Finished removeExistingRps successfullly."); | ||
} catch (Exception e) { | ||
LOG.error("Failed to removed existing RPs.", e); | ||
} | ||
} | ||
|
||
@AfterSuite | ||
public static void afterSuite() { | ||
try { | ||
LOG.debug("Running afterSuite ..."); | ||
SUPPORT.after(); | ||
ServerLauncher.shutdown(false); | ||
LOG.debug("HTTP server is successfully stopped."); | ||
} catch (Exception e) { | ||
LOG.error("Failed to stop HTTP server.", e); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.