gluu
公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 限定公開変数類 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest クラス
org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest の継承関係図
Inheritance graph
org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest 連携図
Collaboration graph

公開メンバ関数

void dynamicClientRegistration (final String registerPath, final String redirectUris) throws Exception
 
void requestAccessToken (final String tokenPath, final String redirectUri) throws Exception
 
void requestAccessTokenPassword (final String tokenPath, final String userId, final String userSecret) throws Exception
 
void requestAccessTokenWithClientSecretJwtFail (final String tokenPath, final String userId, final String userSecret, final String audience) throws Exception
 
void requestAccessTokenClientCredentials (final String tokenPath) throws Exception
 
void refreshingAccessTokenFail (final String tokenPath) throws Exception
 
void initTestSuite (ITestContext context) throws FileNotFoundException, IOException
 
WebDriver getDriver ()
 
void setDriver (WebDriver driver)
 
String getAuthorizationEndpoint ()
 
void setAuthorizationEndpoint (String authorizationEndpoint)
 
String getTokenEndpoint ()
 
void setTokenEndpoint (String tokenEndpoint)
 
String getUserInfoEndpoint ()
 
void setUserInfoEndpoint (String userInfoEndpoint)
 
String getClientInfoEndpoint ()
 
void setClientInfoEndpoint (String clientInfoEndpoint)
 
String getCheckSessionIFrame ()
 
void setCheckSessionIFrame (String checkSessionIFrame)
 
String getEndSessionEndpoint ()
 
void setEndSessionEndpoint (String endSessionEndpoint)
 
String getJwksUri ()
 
void setJwksUri (String jwksUri)
 
String getRegistrationEndpoint ()
 
void setRegistrationEndpoint (String registrationEndpoint)
 
String getIntrospectionEndpoint ()
 
void setIntrospectionEndpoint (String p_introspectionEndpoint)
 
Map< String, List< String > > getScopeToClaimsMapping ()
 
void setScopeToClaimsMapping (Map< String, List< String >> p_scopeToClaimsMapping)
 
String getIdGenEndpoint ()
 
void setIdGenEndpoint (String p_idGenEndpoint)
 
String getConfigurationEndpoint ()
 
void setConfigurationEndpoint (String configurationEndpoint)
 
void startSelenium ()
 
void stopSelenium ()
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies)
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies, boolean useNewDriver)
 
AuthorizationResponse authenticateResourceOwnerAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies, boolean useNewDriver, int authzSteps)
 
AuthorizationResponse authenticateResourceOwnerAndDenyAccess (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
 
AuthorizationResponse authorizationRequestAndGrantAccess (String authorizeUrl, AuthorizationRequest authorizationRequest)
 
AuthorizationResponse authorizationRequestAndDenyAccess (String authorizeUrl, AuthorizationRequest authorizationRequest)
 
AuthorizationResponse authenticateResourceOwner (String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies)
 
String waitForResourceOwnerAndGrantLoginForm (String authorizeUrl, AuthorizationRequest authorizationRequest, boolean cleanupCookies)
 
String waitForResourceOwnerAndGrantLoginForm (String authorizeUrl, AuthorizationRequest authorizationRequest)
 
void discovery (ITestContext context) throws Exception
 
void showTitle (String title)
 
void showTitle (String title)
 
void showEntity (String entity)
 
void showResponse (String title, Response response)
 

静的公開メンバ関数

static void showClient (BaseClient client)
 
static void showClient (BaseClient client, CookieStore cookieStore)
 
static void showClientUserAgent (BaseClient client)
 
static void assertErrorResponse (BaseResponseWithErrors p_response, IErrorType p_errorType)
 
static DefaultHttpClient createHttpClient ()
 
static DefaultHttpClient createHttpClient (HostnameVerifierType p_verifierType)
 
static ClientExecutor clientExecutor () throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
 
static ClientExecutor clientExecutor (boolean trustAll) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
 
static HttpClient createHttpClientTrustAll () throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
 
static void showResponse (String title, Response response, Object entity)
 
static void fails (Throwable e)
 
static void output (String p_msg)
 
static Archive<?> createDeployment ()
 

静的公開変数類

static FileConfiguration testData
 

限定公開変数類

WebDriver driver
 
String authorizationEndpoint
 
String authorizationPageEndpoint
 
String gluuConfigurationEndpoint
 
String tokenEndpoint
 
String userInfoEndpoint
 
String clientInfoEndpoint
 
String checkSessionIFrame
 
String endSessionEndpoint
 
String jwksUri
 
String registrationEndpoint
 
String configurationEndpoint
 
String idGenEndpoint
 
String introspectionEndpoint
 
Map< String, List< String > > scopeToClaimsMapping
 

非公開変数類

URI url
 

静的非公開変数類

static String clientId
 
static String clientSecret
 

詳解

Functional tests for Token Web Services (embedded)

著者
Javier Rojas Blum
バージョン
August 1, 2018

関数詳解

◆ assertErrorResponse()

static void org.xdi.oxauth.BaseTest.assertErrorResponse ( BaseResponseWithErrors  p_response,
IErrorType  p_errorType 
)
inlinestaticinherited
787  {
788  assertEquals(p_response.getStatus(), 400, "Unexpected response code. Entity: " + p_response.getEntity());
789  assertNotNull(p_response.getEntity(), "The entity is null");
790  assertEquals(p_response.getErrorType(), p_errorType);
791  assertTrue(StringUtils.isNotBlank(p_response.getErrorDescription()));
792  }
T getErrorType()
Definition: BaseResponseWithErrors.java:48
String getEntity()
Definition: BaseResponse.java:85
int getStatus()
Definition: BaseResponse.java:49
String getErrorDescription()
Definition: BaseResponseWithErrors.java:40

◆ authenticateResourceOwner()

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwner ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) No authorization page.

556  {
557  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
558 
559  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
560  authorizeClient.setRequest(authorizationRequest);
561 
562  System.out.println("authenticateResourceOwner: authorizationRequestUrl:" + authorizationRequestUrl);
563  startSelenium();
564  if (cleanupCookies) {
565  System.out.println("authenticateResourceOwner: Cleaning cookies");
567  }
568 // try {
569  driver.navigate().to(authorizationRequestUrl);
570 // } catch (WebDriverException ex) {
571 // if (ex.getCause() instanceof ScriptException) {
572 // System.out.println("authenticateResourceOwner: Script error: " + ex.getMessage());
573 // } else {
574 // throw ex;
575 // }
576 // }
577 
578  if (userSecret != null) {
579  if (userId != null) {
580  WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
581  usernameElement.sendKeys(userId);
582  }
583 
584  WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
585  passwordElement.sendKeys(userSecret);
586 
587  WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
588 
589  loginButton.click();
590  }
591 
592  String authorizationResponseStr = driver.getCurrentUrl();
593 
594  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
595  String sessionState = null;
596  if (sessionStateCookie != null) {
597  sessionState = sessionStateCookie.getValue();
598  }
599  System.out.println("authenticateResourceOwner: sessionState:" + sessionState);
600 
601  stopSelenium();
602 
603  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
604  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
605  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
606  }
607  authorizeClient.setResponse(authorizationResponse);
608  showClientUserAgent(authorizeClient);
609 
610  return authorizationResponse;
611  }
FORM_POST
Definition: ResponseMode.java:33
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
void deleteAllCookies()
Definition: BaseTest.java:661
void stopSelenium()
Definition: BaseTest.java:243
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String loginFormLoginButton
Definition: BaseTest.java:90
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ authenticateResourceOwnerAndDenyAccess()

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndDenyAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret 
)
inlineinherited
408  {
409  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
410 
411  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
412  authorizeClient.setRequest(authorizationRequest);
413 
414  System.out.println("authenticateResourceOwnerAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
415  startSelenium();
416  driver.navigate().to(authorizationRequestUrl);
417 
418  WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
419  WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
420  WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
421 
422  if (userId != null) {
423  usernameElement.sendKeys(userId);
424  }
425  passwordElement.sendKeys(userSecret);
426  loginButton.click();
427 
428  String authorizationResponseStr = driver.getCurrentUrl();
429 
430  WebElement doNotAllowButton = driver.findElement(By.id(authorizeFormDoNotAllowButton));
431 
432  final String previousURL = driver.getCurrentUrl();
433  doNotAllowButton.click();
434  WebDriverWait wait = new WebDriverWait(driver, 10);
435  wait.until(new ExpectedCondition<Boolean>() {
436  public Boolean apply(WebDriver d) {
437  return (d.getCurrentUrl() != previousURL);
438  }
439  });
440 
441  authorizationResponseStr = driver.getCurrentUrl();
442 
443  Cookie sessionIdCookie = driver.manage().getCookieNamed("session_id");
444  String sessionId = null;
445  if (sessionIdCookie != null) {
446  sessionId = sessionIdCookie.getValue();
447  }
448  System.out.println("authenticateResourceOwnerAndDenyAccess: sessionId:" + sessionId);
449 
450  stopSelenium();
451 
452  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
453  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
454  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
455  }
456  authorizationResponse.setSessionId(sessionId);
457  authorizeClient.setResponse(authorizationResponse);
458  showClientUserAgent(authorizeClient);
459 
460  return authorizationResponse;
461  }
FORM_POST
Definition: ResponseMode.java:33
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
void stopSelenium()
Definition: BaseTest.java:243
String authorizeFormDoNotAllowButton
Definition: BaseTest.java:92
void setSessionId(String p_sessionId)
Definition: AuthorizationResponse.java:212
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String loginFormLoginButton
Definition: BaseTest.java:90
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ authenticateResourceOwnerAndGrantAccess() [1/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

253  {
254  return authenticateResourceOwnerAndGrantAccess(authorizeUrl, authorizationRequest, userId, userSecret, true);
255  }
AuthorizationResponse authenticateResourceOwnerAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:252

◆ authenticateResourceOwnerAndGrantAccess() [2/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

262  {
263  return authenticateResourceOwnerAndGrantAccess(authorizeUrl, authorizationRequest, userId, userSecret, cleanupCookies, false);
264  }
AuthorizationResponse authenticateResourceOwnerAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:252

◆ authenticateResourceOwnerAndGrantAccess() [3/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies,
boolean  useNewDriver 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

272  {
273  return authenticateResourceOwnerAndGrantAccess(authorizeUrl, authorizationRequest, userId, userSecret, cleanupCookies, useNewDriver, 1);
274  }
AuthorizationResponse authenticateResourceOwnerAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:252

◆ authenticateResourceOwnerAndGrantAccess() [4/4]

AuthorizationResponse org.xdi.oxauth.BaseTest.authenticateResourceOwnerAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
String  userId,
String  userSecret,
boolean  cleanupCookies,
boolean  useNewDriver,
int  authzSteps 
)
inlineinherited

The authorization server authenticates the resource owner (via the user-agent) and establishes whether the resource owner grants or denies the client's access request.

282  {
283  WebDriver currentDriver = initWebDriver(useNewDriver, cleanupCookies);
284 
285  AuthorizeClient authorizeClient = processAuthentication(currentDriver, authorizeUrl, authorizationRequest,
286  userId, userSecret);
287 
288  int remainAuthzSteps = authzSteps;
289 
290  String authorizationResponseStr = null;
291  do {
292  authorizationResponseStr = acceptAuthorization(currentDriver);
293  remainAuthzSteps--;
294  } while (remainAuthzSteps >= 1);
295 
296  AuthorizationResponse authorizationResponse = buildAuthorizationResponse(authorizationRequest, useNewDriver,
297  currentDriver, authorizeClient, authorizationResponseStr);
298 
299  stopWebDriver(useNewDriver, currentDriver);
300 
301  return authorizationResponse;
302  }
AuthorizationResponse buildAuthorizationResponse(AuthorizationRequest authorizationRequest, boolean useNewDriver, WebDriver currentDriver, AuthorizeClient authorizeClient, String authorizationResponseStr)
Definition: BaseTest.java:387
String acceptAuthorization(WebDriver currentDriver)
Definition: BaseTest.java:358
AuthorizeClient processAuthentication(WebDriver currentDriver, String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret)
Definition: BaseTest.java:330
Definition: AuthorizeClient.java:29
WebDriver initWebDriver(boolean useNewDriver, boolean cleanupCookies)
Definition: BaseTest.java:304
Definition: AuthorizationResponse.java:32
void stopWebDriver(boolean useNewDriver, WebDriver currentDriver)
Definition: BaseTest.java:321

◆ authorizationRequestAndDenyAccess()

AuthorizationResponse org.xdi.oxauth.BaseTest.authorizationRequestAndDenyAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest 
)
inlineinherited
509  {
510  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
511 
512  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
513  authorizeClient.setRequest(authorizationRequest);
514 
515  System.out.println("authorizationRequestAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
516  startSelenium();
517  driver.navigate().to(authorizationRequestUrl);
518 
519  WebElement doNotAllowButton = driver.findElement(By.id(authorizeFormDoNotAllowButton));
520 
521  final String previousURL = driver.getCurrentUrl();
522  doNotAllowButton.click();
523  WebDriverWait wait = new WebDriverWait(driver, 10);
524  wait.until(new ExpectedCondition<Boolean>() {
525  public Boolean apply(WebDriver d) {
526  return (d.getCurrentUrl() != previousURL);
527  }
528  });
529 
530  String authorizationResponseStr = driver.getCurrentUrl();
531 
532  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
533  String sessionState = null;
534  if (sessionStateCookie != null) {
535  sessionState = sessionStateCookie.getValue();
536  }
537  System.out.println("authorizationRequestAndDenyAccess: sessionState:" + sessionState);
538 
539  stopSelenium();
540 
541  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
542  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
543  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
544  }
545  authorizeClient.setResponse(authorizationResponse);
546  showClientUserAgent(authorizeClient);
547 
548  return authorizationResponse;
549  }
FORM_POST
Definition: ResponseMode.java:33
void stopSelenium()
Definition: BaseTest.java:243
String authorizeFormDoNotAllowButton
Definition: BaseTest.java:92
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ authorizationRequestAndGrantAccess()

AuthorizationResponse org.xdi.oxauth.BaseTest.authorizationRequestAndGrantAccess ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest 
)
inlineinherited
464  {
465  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
466 
467  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
468  authorizeClient.setRequest(authorizationRequest);
469 
470  System.out.println("authorizationRequestAndGrantAccess: authorizationRequestUrl:" + authorizationRequestUrl);
471  startSelenium();
472  driver.navigate().to(authorizationRequestUrl);
473 
474  String authorizationResponseStr = driver.getCurrentUrl();
475 
476  WebElement allowButton = driver.findElement(By.id(authorizeFormAllowButton));
477 
478  final String previousURL = driver.getCurrentUrl();
479  allowButton.click();
480  WebDriverWait wait = new WebDriverWait(driver, 10);
481  wait.until(new ExpectedCondition<Boolean>() {
482  public Boolean apply(WebDriver d) {
483  return (d.getCurrentUrl() != previousURL);
484  }
485  });
486 
487  authorizationResponseStr = driver.getCurrentUrl();
488 
489  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
490  String sessionState = null;
491  if (sessionStateCookie != null) {
492  sessionState = sessionStateCookie.getValue();
493  }
494  System.out.println("authorizationRequestAndGrantAccess: sessionState:" + sessionState);
495 
496  stopSelenium();
497 
498  AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
499  if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
500  authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
501  }
502  authorizeClient.setResponse(authorizationResponse);
503  showClientUserAgent(authorizeClient);
504 
505  return authorizationResponse;
506  }
FORM_POST
Definition: ResponseMode.java:33
void stopSelenium()
Definition: BaseTest.java:243
Definition: AuthorizeClient.java:29
Definition: ResponseMode.java:16
void startSelenium()
Definition: BaseTest.java:230
String getRedirectUri()
Definition: AuthorizationRequest.java:184
void setResponseMode(ResponseMode responseMode)
Definition: AuthorizationResponse.java:228
void setRequest(T request)
Definition: BaseClient.java:68
void setResponse(V response)
Definition: BaseClient.java:76
WebDriver driver
Definition: BaseTest.java:70
Definition: AuthorizationResponse.java:32
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783
String authorizeFormAllowButton
Definition: BaseTest.java:91

◆ clientExecutor() [1/2]

static ClientExecutor org.xdi.oxauth.BaseTest.clientExecutor ( ) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
inlinestaticinherited
822  {
823  return clientExecutor(false);
824  }
static ClientExecutor clientExecutor()
Definition: BaseTest.java:822

◆ clientExecutor() [2/2]

static ClientExecutor org.xdi.oxauth.BaseTest.clientExecutor ( boolean  trustAll) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
inlinestaticinherited
826  {
827  if (trustAll) {
828  return new ApacheHttpClient4Executor(createHttpClientTrustAll());
829  }
830  return ClientRequest.getDefaultExecutor();
831  }
static HttpClient createHttpClientTrustAll()
Definition: BaseTest.java:833

◆ createDeployment()

static Archive<?> org.xdi.oxauth.ConfigurableTest.createDeployment ( )
inlinestaticinherited
40  {
41  return Deployments.createDeployment();
42  }

◆ createHttpClient() [1/2]

static DefaultHttpClient org.xdi.oxauth.BaseTest.createHttpClient ( )
inlinestaticinherited
794  {
795  return createHttpClient(HostnameVerifierType.DEFAULT);
796  }
static DefaultHttpClient createHttpClient()
Definition: BaseTest.java:794

◆ createHttpClient() [2/2]

static DefaultHttpClient org.xdi.oxauth.BaseTest.createHttpClient ( HostnameVerifierType  p_verifierType)
inlinestaticinherited
798  {
799  if (p_verifierType != null && p_verifierType != HostnameVerifierType.DEFAULT) {
800  switch (p_verifierType) {
801  case ALLOW_ALL:
802  HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
803 
804  DefaultHttpClient client = new DefaultHttpClient();
805 
806  SchemeRegistry registry = new SchemeRegistry();
807  SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
808  socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
809  registry.register(new Scheme("https", socketFactory, 443));
810  SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
811 
812  // Set verifier
813  HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
814  return new DefaultHttpClient(mgr, client.getParams());
815  case DEFAULT:
816  return new DefaultHttpClient();
817  }
818  }
819  return new DefaultHttpClient();
820  }

◆ createHttpClientTrustAll()

static HttpClient org.xdi.oxauth.BaseTest.createHttpClientTrustAll ( ) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
inlinestaticinherited
833  {
834  SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {
835  @Override
836  public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
837  return true;
838  }
839  }, new AllowAllHostnameVerifier());
840 
841  SchemeRegistry registry = new SchemeRegistry();
842  registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
843  registry.register(new Scheme("https", 443, sf));
844  ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
845  return new DefaultHttpClient(ccm);
846  }

◆ discovery()

void org.xdi.oxauth.BaseTest.discovery ( ITestContext  context) throws Exception
inlineinherited
670  {
671  // Load Form Interaction
672  loginFormUsername = context.getCurrentXmlTest().getParameter("loginFormUsername");
673  loginFormPassword = context.getCurrentXmlTest().getParameter("loginFormPassword");
674  loginFormLoginButton = context.getCurrentXmlTest().getParameter("loginFormLoginButton");
675  authorizeFormAllowButton = context.getCurrentXmlTest().getParameter("authorizeFormAllowButton");
676  authorizeFormDoNotAllowButton = context.getCurrentXmlTest().getParameter("authorizeFormDoNotAllowButton");
677 
678  String resource = context.getCurrentXmlTest().getParameter("swdResource");
679 
680  if (StringUtils.isNotBlank(resource)) {
681 
682  showTitle("OpenID Connect Discovery");
683 
684  OpenIdConnectDiscoveryClient openIdConnectDiscoveryClient = new OpenIdConnectDiscoveryClient(resource);
685  OpenIdConnectDiscoveryResponse openIdConnectDiscoveryResponse = openIdConnectDiscoveryClient.exec(clientExecutor(true));
686 
687  showClient(openIdConnectDiscoveryClient);
688  assertEquals(openIdConnectDiscoveryResponse.getStatus(), 200, "Unexpected response code");
689  assertNotNull(openIdConnectDiscoveryResponse.getSubject());
690  assertTrue(openIdConnectDiscoveryResponse.getLinks().size() > 0);
691 
692  configurationEndpoint = openIdConnectDiscoveryResponse.getLinks().get(0).getHref() +
693  "/.well-known/openid-configuration";
694 
695  System.out.println("OpenID Connect Configuration");
696 
697  OpenIdConfigurationClient client = new OpenIdConfigurationClient(configurationEndpoint);
698  client.setExecutor(clientExecutor(true));
700 
701  showClient(client);
702  assertEquals(response.getStatus(), 200, "Unexpected response code");
703  assertNotNull(response.getIssuer(), "The issuer is null");
704  assertNotNull(response.getAuthorizationEndpoint(), "The authorizationEndpoint is null");
705  assertNotNull(response.getTokenEndpoint(), "The tokenEndpoint is null");
706  assertNotNull(response.getUserInfoEndpoint(), "The userInfoEndPoint is null");
707  assertNotNull(response.getJwksUri(), "The jwksUri is null");
708  assertNotNull(response.getRegistrationEndpoint(), "The registrationEndpoint is null");
709 
710  assertTrue(response.getScopesSupported().size() > 0, "The scopesSupported is empty");
711  assertTrue(response.getScopeToClaimsMapping().size() > 0, "The scope to claims mapping is empty");
712  assertTrue(response.getResponseTypesSupported().size() > 0, "The responseTypesSupported is empty");
713  assertTrue(response.getGrantTypesSupported().size() > 0, "The grantTypesSupported is empty");
714  assertTrue(response.getAcrValuesSupported().size() >= 0, "The acrValuesSupported is empty");
715  assertTrue(response.getSubjectTypesSupported().size() > 0, "The subjectTypesSupported is empty");
716  assertTrue(response.getIdTokenSigningAlgValuesSupported().size() > 0, "The idTokenSigningAlgValuesSupported is empty");
717  assertTrue(response.getRequestObjectSigningAlgValuesSupported().size() > 0, "The requestObjectSigningAlgValuesSupported is empty");
718  assertTrue(response.getTokenEndpointAuthMethodsSupported().size() > 0, "The tokenEndpointAuthMethodsSupported is empty");
719  assertTrue(response.getClaimsSupported().size() > 0, "The claimsSupported is empty");
720 
722  tokenEndpoint = response.getTokenEndpoint();
727  jwksUri = response.getJwksUri();
732  gluuConfigurationEndpoint = determineGluuConfigurationEndpoint(openIdConnectDiscoveryResponse.getLinks().get(0).getHref());
733  } else {
734  showTitle("Loading configuration endpoints from properties file");
735 
736  authorizationEndpoint = context.getCurrentXmlTest().getParameter("authorizationEndpoint");
737  tokenEndpoint = context.getCurrentXmlTest().getParameter("tokenEndpoint");
738  userInfoEndpoint = context.getCurrentXmlTest().getParameter("userInfoEndpoint");
739  clientInfoEndpoint = context.getCurrentXmlTest().getParameter("clientInfoEndpoint");
740  checkSessionIFrame = context.getCurrentXmlTest().getParameter("checkSessionIFrame");
741  endSessionEndpoint = context.getCurrentXmlTest().getParameter("endSessionEndpoint");
742  jwksUri = context.getCurrentXmlTest().getParameter("jwksUri");
743  registrationEndpoint = context.getCurrentXmlTest().getParameter("registrationEndpoint");
744  configurationEndpoint = context.getCurrentXmlTest().getParameter("configurationEndpoint");
745  idGenEndpoint = context.getCurrentXmlTest().getParameter("idGenEndpoint");
746  introspectionEndpoint = context.getCurrentXmlTest().getParameter("introspectionEndpoint");
747  scopeToClaimsMapping = new HashMap<String, List<String>>();
748  }
749 
751  }
String registrationEndpoint
Definition: BaseTest.java:81
String getIntrospectionEndpoint()
Definition: OpenIdConfigurationResponse.java:343
List< String > getTokenEndpointAuthMethodsSupported()
Definition: OpenIdConfigurationResponse.java:642
String determineAuthorizationPageEndpoint(String authorizationEndpoint)
Definition: BaseTest.java:753
String jwksUri
Definition: BaseTest.java:80
String getRegistrationEndpoint()
Definition: OpenIdConfigurationResponse.java:310
String clientInfoEndpoint
Definition: BaseTest.java:77
String getCheckSessionIFrame()
Definition: OpenIdConfigurationResponse.java:248
String authorizationPageEndpoint
Definition: BaseTest.java:73
String idGenEndpoint
Definition: BaseTest.java:83
String getIdGenerationEndpoint()
Definition: OpenIdConfigurationResponse.java:327
static void showClient(BaseClient client)
Definition: BaseTest.java:775
List< String > getRequestObjectSigningAlgValuesSupported()
Definition: OpenIdConfigurationResponse.java:579
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
String configurationEndpoint
Definition: BaseTest.java:82
List< String > getSubjectTypesSupported()
Definition: OpenIdConfigurationResponse.java:438
String getEndSessionEndpoint()
Definition: OpenIdConfigurationResponse.java:268
String tokenEndpoint
Definition: BaseTest.java:75
String authorizeFormDoNotAllowButton
Definition: BaseTest.java:92
List< String > getAcrValuesSupported()
Definition: OpenIdConfigurationResponse.java:418
String getClientInfoEndpoint()
Definition: OpenIdConfigurationResponse.java:228
List< String > getGrantTypesSupported()
Definition: OpenIdConfigurationResponse.java:398
String checkSessionIFrame
Definition: BaseTest.java:78
void setExecutor(ClientExecutor executor)
Definition: BaseClient.java:84
OpenIdConfigurationResponse execOpenIdConfiguration()
Definition: OpenIdConfigurationClient.java:47
String loginFormLoginButton
Definition: BaseTest.java:90
String gluuConfigurationEndpoint
Definition: BaseTest.java:74
Map< String, List< String > > getScopeToClaimsMapping()
Definition: OpenIdConfigurationResponse.java:136
String getJwksUri()
Definition: OpenIdConfigurationResponse.java:289
String getTokenEndpoint()
Definition: OpenIdConfigurationResponse.java:192
List< String > getIdTokenSigningAlgValuesSupported()
Definition: OpenIdConfigurationResponse.java:519
Definition: OpenIdConnectDiscoveryClient.java:29
String introspectionEndpoint
Definition: BaseTest.java:84
void showTitle(String title)
Definition: BaseTest.java:761
List< String > getResponseTypesSupported()
Definition: OpenIdConfigurationResponse.java:378
String endSessionEndpoint
Definition: BaseTest.java:79
String getSubject()
Definition: OpenIdConnectDiscoveryResponse.java:32
List< String > getScopesSupported()
Definition: OpenIdConfigurationResponse.java:360
String determineGluuConfigurationEndpoint(String host)
Definition: BaseTest.java:757
OpenIdConnectDiscoveryResponse exec()
Definition: OpenIdConnectDiscoveryClient.java:47
String getAuthorizationEndpoint()
Definition: OpenIdConfigurationResponse.java:174
String userInfoEndpoint
Definition: BaseTest.java:76
Definition: OpenIdConfigurationClient.java:27
int getStatus()
Definition: BaseResponse.java:49
List< WebFingerLink > getLinks()
Definition: OpenIdConnectDiscoveryResponse.java:40
List< String > getClaimsSupported()
Definition: OpenIdConfigurationResponse.java:728
Definition: OpenIdConnectDiscoveryResponse.java:17
String authorizationEndpoint
Definition: BaseTest.java:72
String getUserInfoEndpoint()
Definition: OpenIdConfigurationResponse.java:210
Definition: OpenIdConfigurationResponse.java:26
static ClientExecutor clientExecutor()
Definition: BaseTest.java:822
Map< String, List< String > > scopeToClaimsMapping
Definition: BaseTest.java:85
String authorizeFormAllowButton
Definition: BaseTest.java:91
String getIssuer()
Definition: OpenIdConfigurationResponse.java:156

◆ dynamicClientRegistration()

void org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.dynamicClientRegistration ( final String  registerPath,
final String  redirectUris 
) throws Exception
inline
52  {
53  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
54 
55  String registerRequestContent = null;
56  try {
57  List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE, ResponseType.TOKEN,
58  ResponseType.ID_TOKEN);
59 
60  RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
61  StringUtils.spaceSeparatedToList(redirectUris));
62  registerRequest.setResponseTypes(responseTypes);
63  registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
64 
65  List<GrantType> grantTypes = Arrays.asList(
66  GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS,
67  GrantType.CLIENT_CREDENTIALS
68  );
69  registerRequest.setGrantTypes(grantTypes);
70 
71  registerRequestContent = registerRequest.getJSONParameters().toString(4);
72  } catch (JSONException e) {
73  e.printStackTrace();
74  fail(e.getMessage());
75  }
76 
77  Response response = request.post(Entity.json(registerRequestContent));
78  String entity = response.readEntity(String.class);
79 
80  showResponse("dynamicClientRegistration", response, entity);
81 
82  assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
83  assertNotNull(entity, "Unexpected result: " + entity);
84  try {
85  final RegisterResponse registerResponse = RegisterResponse.valueOf(entity);
86  ClientTestUtil.assert_(registerResponse);
87 
88  clientId = registerResponse.getClientId();
89  clientSecret = registerResponse.getClientSecret();
90  } catch (Exception e) {
91  e.printStackTrace();
92  fail(e.getMessage() + "\nResponse was: " + entity);
93  }
94  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientSecret
Definition: TokenRestWebServiceEmbeddedTest.java:48
URI url
Definition: TokenRestWebServiceEmbeddedTest.java:45
static String clientId
Definition: TokenRestWebServiceEmbeddedTest.java:47

◆ fails()

static void org.xdi.oxauth.BaseTest.fails ( Throwable  e)
inlinestaticinherited
50  {
51  Assert.fail(e.getMessage(), e);
52  }

◆ getAuthorizationEndpoint()

String org.xdi.oxauth.BaseTest.getAuthorizationEndpoint ( )
inlineinherited
134  {
135  return authorizationEndpoint;
136  }
String authorizationEndpoint
Definition: BaseTest.java:72

◆ getCheckSessionIFrame()

String org.xdi.oxauth.BaseTest.getCheckSessionIFrame ( )
inlineinherited
166  {
167  return checkSessionIFrame;
168  }
String checkSessionIFrame
Definition: BaseTest.java:78

◆ getClientInfoEndpoint()

String org.xdi.oxauth.BaseTest.getClientInfoEndpoint ( )
inlineinherited
158  {
159  return clientInfoEndpoint;
160  }
String clientInfoEndpoint
Definition: BaseTest.java:77

◆ getConfigurationEndpoint()

String org.xdi.oxauth.BaseTest.getConfigurationEndpoint ( )
inlineinherited
222  {
223  return configurationEndpoint;
224  }
String configurationEndpoint
Definition: BaseTest.java:82

◆ getDriver()

WebDriver org.xdi.oxauth.BaseTest.getDriver ( )
inlineinherited
126  {
127  return driver;
128  }
WebDriver driver
Definition: BaseTest.java:70

◆ getEndSessionEndpoint()

String org.xdi.oxauth.BaseTest.getEndSessionEndpoint ( )
inlineinherited
174  {
175  return endSessionEndpoint;
176  }
String endSessionEndpoint
Definition: BaseTest.java:79

◆ getIdGenEndpoint()

String org.xdi.oxauth.BaseTest.getIdGenEndpoint ( )
inlineinherited
214  {
215  return idGenEndpoint;
216  }
String idGenEndpoint
Definition: BaseTest.java:83

◆ getIntrospectionEndpoint()

String org.xdi.oxauth.BaseTest.getIntrospectionEndpoint ( )
inlineinherited
198  {
199  return introspectionEndpoint;
200  }
String introspectionEndpoint
Definition: BaseTest.java:84

◆ getJwksUri()

String org.xdi.oxauth.BaseTest.getJwksUri ( )
inlineinherited
182  {
183  return jwksUri;
184  }
String jwksUri
Definition: BaseTest.java:80

◆ getRegistrationEndpoint()

String org.xdi.oxauth.BaseTest.getRegistrationEndpoint ( )
inlineinherited
190  {
191  return registrationEndpoint;
192  }
String registrationEndpoint
Definition: BaseTest.java:81

◆ getScopeToClaimsMapping()

Map<String, List<String> > org.xdi.oxauth.BaseTest.getScopeToClaimsMapping ( )
inlineinherited
206  {
207  return scopeToClaimsMapping;
208  }
Map< String, List< String > > scopeToClaimsMapping
Definition: BaseTest.java:85

◆ getTokenEndpoint()

String org.xdi.oxauth.BaseTest.getTokenEndpoint ( )
inlineinherited
142  {
143  return tokenEndpoint;
144  }
String tokenEndpoint
Definition: BaseTest.java:75

◆ getUserInfoEndpoint()

String org.xdi.oxauth.BaseTest.getUserInfoEndpoint ( )
inlineinherited
150  {
151  return userInfoEndpoint;
152  }
String userInfoEndpoint
Definition: BaseTest.java:76

◆ initTestSuite()

void org.xdi.oxauth.BaseTest.initTestSuite ( ITestContext  context) throws FileNotFoundException, IOException
inlineinherited
95  {
96  SecurityProviderUtility.installBCProvider();
97 
98  Reporter.log("Invoked init test suite method \n", true);
99 
100  String propertiesFile = context.getCurrentXmlTest().getParameter("propertiesFile");
101  if (StringHelper.isEmpty(propertiesFile)) {
102  propertiesFile = "target/test-classes/testng.properties";
103  //propertiesFile = "U:\\own\\project\\git\\oxAuth\\Client\\src\\test\\resources\\testng_yuriy.properties";
104  //propertiesFile = "/Users/JAVIER/IdeaProjects/oxAuth/Client/target/test-classes/testng.properties";
105  }
106 
107  FileInputStream conf = new FileInputStream(propertiesFile);
108  Properties prop = new Properties();
109  prop.load(conf);
110 
111  Map<String, String> parameters = new HashMap<String, String>();
112  for (Entry<Object, Object> entry : prop.entrySet()) {
113  Object key = entry.getKey();
114  Object value = entry.getValue();
115 
116  if (StringHelper.isEmptyString(key) || StringHelper.isEmptyString(value)) {
117  continue;
118  }
119  parameters.put(key.toString(), value.toString());
120  }
121 
122  // Overrided test paramters
123  context.getSuite().getXmlSuite().setParameters(parameters);
124  }

◆ output()

static void org.xdi.oxauth.BaseTest.output ( String  p_msg)
inlinestaticinherited
54  {
55  System.out.println(p_msg);
56  }

◆ refreshingAccessTokenFail()

void org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.refreshingAccessTokenFail ( final String  tokenPath) throws Exception
inline
246  {
247  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
248 
249  TokenRequest tokenRequest = new TokenRequest(GrantType.REFRESH_TOKEN);
250  tokenRequest.setRefreshToken("tGzv3JOkF0XG5Qx2TlKWIA");
251  tokenRequest.setScope("email read_stream manage_pages");
252  tokenRequest.setAuthUsername(clientId);
253  tokenRequest.setAuthPassword(clientSecret);
254 
255  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
256  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
257 
258  Response response = request
259  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
260  String entity = response.readEntity(String.class);
261 
262  showResponse("refreshingAccessTokenFail", response, entity);
263 
264  assertEquals(response.getStatus(), 401, "Unexpected response code.");
265  assertNotNull(entity, "Unexpected result: " + entity);
266  try {
267  JSONObject jsonObj = new JSONObject(entity);
268  assertTrue(jsonObj.has("error"), "The error type is null");
269  assertTrue(jsonObj.has("error_description"), "The error description is null");
270  } catch (JSONException e) {
271  e.printStackTrace();
272  fail(e.getMessage() + "\nResponse was: " + entity);
273  }
274  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientSecret
Definition: TokenRestWebServiceEmbeddedTest.java:48
URI url
Definition: TokenRestWebServiceEmbeddedTest.java:45
static String clientId
Definition: TokenRestWebServiceEmbeddedTest.java:47

◆ requestAccessToken()

void org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.requestAccessToken ( final String  tokenPath,
final String  redirectUri 
) throws Exception
inline
98  {
99  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
100 
101  TokenRequest tokenRequest = new TokenRequest(GrantType.AUTHORIZATION_CODE);
102  tokenRequest.setCode("6f6f3f01-a034-4336-bf31-2e74868e5838");
103  tokenRequest.setRedirectUri(redirectUri);
104  tokenRequest.setAuthUsername(clientId);
105  tokenRequest.setAuthPassword(clientSecret);
106 
107  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
108  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
109 
110  Response response = request
111  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
112  String entity = response.readEntity(String.class);
113 
114  showResponse("requestAccessToken", response, entity);
115 
116  assertEquals(response.getStatus(), 400, "Unexpected response code.");
117  assertNotNull(entity, "Unexpected result: " + entity);
118  try {
119  JSONObject jsonObj = new JSONObject(entity);
120  assertTrue(jsonObj.has("error"), "The error type is null");
121  assertTrue(jsonObj.has("error_description"), "The error description is null");
122  } catch (JSONException e) {
123  e.printStackTrace();
124  fail(e.getMessage() + "\nResponse was: " + entity);
125  }
126  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientSecret
Definition: TokenRestWebServiceEmbeddedTest.java:48
URI url
Definition: TokenRestWebServiceEmbeddedTest.java:45
static String clientId
Definition: TokenRestWebServiceEmbeddedTest.java:47

◆ requestAccessTokenClientCredentials()

void org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.requestAccessTokenClientCredentials ( final String  tokenPath) throws Exception
inline
207  {
208  // Testing with valid parameters
209  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
210 
211  TokenRequest tokenRequest = new TokenRequest(GrantType.CLIENT_CREDENTIALS);
212  tokenRequest.setScope("email read_stream manage_pages");
213  tokenRequest.setAuthUsername(clientId);
214  tokenRequest.setAuthPassword(clientSecret);
215 
216  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
217  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
218 
219  Response response = request
220  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
221  String entity = response.readEntity(String.class);
222 
223  showResponse("requestAccessTokenClientCredentials", response, entity);
224 
225  assertEquals(response.getStatus(), 200, "Unexpected response code.");
226  assertTrue(
227  response.getHeaderString("Cache-Control") != null
228  && response.getHeaderString("Cache-Control").equals("no-store"),
229  "Unexpected result: " + response.getHeaderString("Cache-Control"));
230  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
231  "Unexpected result: " + response.getHeaderString("Pragma"));
232  assertNotNull(entity, "Unexpected result: " + entity);
233  try {
234  JSONObject jsonObj = new JSONObject(entity);
235  assertTrue(jsonObj.has("access_token"), "Unexpected result: access_token not found");
236  assertTrue(jsonObj.has("token_type"), "Unexpected result: token_type not found");
237  assertTrue(jsonObj.has("scope"), "Unexpected result: scope not found");
238  } catch (JSONException e) {
239  e.printStackTrace();
240  fail(e.getMessage() + "\nResponse was: " + entity);
241  }
242  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientSecret
Definition: TokenRestWebServiceEmbeddedTest.java:48
URI url
Definition: TokenRestWebServiceEmbeddedTest.java:45
static String clientId
Definition: TokenRestWebServiceEmbeddedTest.java:47

◆ requestAccessTokenPassword()

void org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.requestAccessTokenPassword ( final String  tokenPath,
final String  userId,
final String  userSecret 
) throws Exception
inline
131  {
132  // Testing with valid parameters
133  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
134 
135  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
136  tokenRequest.setUsername(userId);
137  tokenRequest.setPassword(userSecret);
138  tokenRequest.setScope("email read_stream manage_pages");
139  tokenRequest.setAuthUsername(clientId);
140  tokenRequest.setAuthPassword(clientSecret);
141 
142  request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
143  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
144 
145  Response response = request
146  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
147  String entity = response.readEntity(String.class);
148 
149  showResponse("requestAccessTokenPassword", response, entity);
150 
151  assertEquals(response.getStatus(), 200, "Unexpected response code.");
152  assertTrue(
153  response.getHeaderString("Cache-Control") != null
154  && response.getHeaderString("Cache-Control").equals("no-store"),
155  "Unexpected result: " + response.getHeaderString("Cache-Control"));
156  assertTrue(response.getHeaderString("Pragma") != null && response.getHeaderString("Pragma").equals("no-cache"),
157  "Unexpected result: " + response.getHeaderString("Pragma"));
158  assertNotNull(entity, "Unexpected result: " + entity);
159  try {
160  JSONObject jsonObj = new JSONObject(entity);
161  assertTrue(jsonObj.has("access_token"), "Unexpected result: access_token not found");
162  assertTrue(jsonObj.has("token_type"), "Unexpected result: token_type not found");
163  assertTrue(jsonObj.has("refresh_token"), "Unexpected result: refresh_token not found");
164  assertTrue(jsonObj.has("scope"), "Unexpected result: scope not found");
165  } catch (JSONException e) {
166  e.printStackTrace();
167  fail(e.getMessage() + "\nResponse was: " + entity);
168  }
169  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30
static String clientSecret
Definition: TokenRestWebServiceEmbeddedTest.java:48
URI url
Definition: TokenRestWebServiceEmbeddedTest.java:45
static String clientId
Definition: TokenRestWebServiceEmbeddedTest.java:47

◆ requestAccessTokenWithClientSecretJwtFail()

void org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.requestAccessTokenWithClientSecretJwtFail ( final String  tokenPath,
final String  userId,
final String  userSecret,
final String  audience 
) throws Exception
inline
174  {
175  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request();
176  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
177 
178  TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
179  tokenRequest.setUsername(userId);
180  tokenRequest.setPassword(userSecret);
181  tokenRequest.setScope("email read_stream manage_pages");
182 
183  tokenRequest.setAuthPassword("INVALID_SECRET");
184  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_JWT);
185  tokenRequest.setAudience(audience);
186 
187  Response response = request
188  .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
189  String entity = response.readEntity(String.class);
190 
191  showResponse("requestAccessTokenWithClientSecretJwt Fail", response, entity);
192 
193  assertEquals(response.getStatus(), 401, "Unexpected response code.");
194  assertNotNull(entity, "Unexpected result: " + entity);
195  try {
196  JSONObject jsonObj = new JSONObject(entity);
197  assertTrue(jsonObj.has("error"), "The error type is null");
198  assertTrue(jsonObj.has("error_description"), "The error description is null");
199  } catch (JSONException e) {
200  e.printStackTrace();
201  fail(e.getMessage() + "\nResponse was: " + entity);
202  }
203  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30
URI url
Definition: TokenRestWebServiceEmbeddedTest.java:45

◆ setAuthorizationEndpoint()

void org.xdi.oxauth.BaseTest.setAuthorizationEndpoint ( String  authorizationEndpoint)
inlineinherited
138  {
140  }
String authorizationEndpoint
Definition: BaseTest.java:72

◆ setCheckSessionIFrame()

void org.xdi.oxauth.BaseTest.setCheckSessionIFrame ( String  checkSessionIFrame)
inlineinherited
170  {
172  }
String checkSessionIFrame
Definition: BaseTest.java:78

◆ setClientInfoEndpoint()

void org.xdi.oxauth.BaseTest.setClientInfoEndpoint ( String  clientInfoEndpoint)
inlineinherited
162  {
164  }
String clientInfoEndpoint
Definition: BaseTest.java:77

◆ setConfigurationEndpoint()

void org.xdi.oxauth.BaseTest.setConfigurationEndpoint ( String  configurationEndpoint)
inlineinherited
226  {
228  }
String configurationEndpoint
Definition: BaseTest.java:82

◆ setDriver()

void org.xdi.oxauth.BaseTest.setDriver ( WebDriver  driver)
inlineinherited
130  {
131  this.driver = driver;
132  }
WebDriver driver
Definition: BaseTest.java:70

◆ setEndSessionEndpoint()

void org.xdi.oxauth.BaseTest.setEndSessionEndpoint ( String  endSessionEndpoint)
inlineinherited
178  {
180  }
String endSessionEndpoint
Definition: BaseTest.java:79

◆ setIdGenEndpoint()

void org.xdi.oxauth.BaseTest.setIdGenEndpoint ( String  p_idGenEndpoint)
inlineinherited
218  {
219  idGenEndpoint = p_idGenEndpoint;
220  }
String idGenEndpoint
Definition: BaseTest.java:83

◆ setIntrospectionEndpoint()

void org.xdi.oxauth.BaseTest.setIntrospectionEndpoint ( String  p_introspectionEndpoint)
inlineinherited
202  {
203  introspectionEndpoint = p_introspectionEndpoint;
204  }
String introspectionEndpoint
Definition: BaseTest.java:84

◆ setJwksUri()

void org.xdi.oxauth.BaseTest.setJwksUri ( String  jwksUri)
inlineinherited
186  {
187  this.jwksUri = jwksUri;
188  }
String jwksUri
Definition: BaseTest.java:80

◆ setRegistrationEndpoint()

void org.xdi.oxauth.BaseTest.setRegistrationEndpoint ( String  registrationEndpoint)
inlineinherited
194  {
196  }
String registrationEndpoint
Definition: BaseTest.java:81

◆ setScopeToClaimsMapping()

void org.xdi.oxauth.BaseTest.setScopeToClaimsMapping ( Map< String, List< String >>  p_scopeToClaimsMapping)
inlineinherited
210  {
211  scopeToClaimsMapping = p_scopeToClaimsMapping;
212  }
Map< String, List< String > > scopeToClaimsMapping
Definition: BaseTest.java:85

◆ setTokenEndpoint()

void org.xdi.oxauth.BaseTest.setTokenEndpoint ( String  tokenEndpoint)
inlineinherited
146  {
148  }
String tokenEndpoint
Definition: BaseTest.java:75

◆ setUserInfoEndpoint()

void org.xdi.oxauth.BaseTest.setUserInfoEndpoint ( String  userInfoEndpoint)
inlineinherited
154  {
156  }
String userInfoEndpoint
Definition: BaseTest.java:76

◆ showClient() [1/2]

static void org.xdi.oxauth.BaseTest.showClient ( BaseClient  client)
inlinestaticinherited
775  {
776  ClientUtils.showClient(client);
777  }
Definition: ClientUtils.java:17
static void showClient(BaseClient client)
Definition: ClientUtils.java:21

◆ showClient() [2/2]

static void org.xdi.oxauth.BaseTest.showClient ( BaseClient  client,
CookieStore  cookieStore 
)
inlinestaticinherited
779  {
780  ClientUtils.showClient(client, cookieStore);
781  }
Definition: ClientUtils.java:17
static void showClient(BaseClient client)
Definition: ClientUtils.java:21

◆ showClientUserAgent()

static void org.xdi.oxauth.BaseTest.showClientUserAgent ( BaseClient  client)
inlinestaticinherited
783  {
785  }
Definition: ClientUtils.java:17
static void showClientUserAgent(BaseClient client)
Definition: ClientUtils.java:35

◆ showEntity()

void org.xdi.oxauth.BaseTest.showEntity ( String  entity)
inlineinherited
769  {
770  if (entity != null) {
771  System.out.println("Entity: " + entity.replace("\\n", "\n"));
772  }
773  }

◆ showResponse() [1/2]

void org.xdi.oxauth.BaseTest.showResponse ( String  title,
Response  response 
)
inlineinherited
30  {
31  showResponse(title, response, null);
32  }
void showResponse(String title, Response response)
Definition: BaseTest.java:30

◆ showResponse() [2/2]

static void org.xdi.oxauth.BaseTest.showResponse ( String  title,
Response  response,
Object  entity 
)
inlinestaticinherited
34  {
35  System.out.println(" ");
36  System.out.println("RESPONSE FOR: " + title);
37  System.out.println(response.getStatus());
38  for (Entry<String, List<Object>> headers : response.getHeaders().entrySet()) {
39  String headerName = headers.getKey();
40  System.out.println(headerName + ": " + headers.getValue());
41  }
42 
43  if (entity != null) {
44  System.out.println(entity.toString().replace("\\n", "\n"));
45  }
46  System.out.println(" ");
47  System.out.println("Status message: " + response.getStatus());
48  }

◆ showTitle() [1/2]

void org.xdi.oxauth.BaseTest.showTitle ( String  title)
inlineinherited
22  {
23  title = "TEST: " + title;
24 
25  System.out.println("#######################################################");
26  System.out.println(title);
27  System.out.println("#######################################################");
28  }

◆ showTitle() [2/2]

void org.xdi.oxauth.BaseTest.showTitle ( String  title)
inlineinherited
761  {
762  title = "TEST: " + title;
763 
764  System.out.println("#######################################################");
765  System.out.println(title);
766  System.out.println("#######################################################");
767  }

◆ startSelenium()

void org.xdi.oxauth.BaseTest.startSelenium ( )
inlineinherited
230  {
231  //System.setProperty("webdriver.chrome.driver", "/Users/JAVIER/tmp/chromedriver");
232  //driver = new ChromeDriver();
233 
234  //driver = new SafariDriver();
235 
236  //driver = new FirefoxDriver();
237 
238  //driver = new InternetExplorerDriver();
239 
240  driver = new HtmlUnitDriver(true);
241  }
WebDriver driver
Definition: BaseTest.java:70

◆ stopSelenium()

void org.xdi.oxauth.BaseTest.stopSelenium ( )
inlineinherited
243  {
244 // driver.close();
245  driver.quit();
246  }
WebDriver driver
Definition: BaseTest.java:70

◆ waitForResourceOwnerAndGrantLoginForm() [1/2]

String org.xdi.oxauth.BaseTest.waitForResourceOwnerAndGrantLoginForm ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest,
boolean  cleanupCookies 
)
inlineinherited

Try to open login form (via the user-agent)

617  {
618  String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
619 
620  AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
621  authorizeClient.setRequest(authorizationRequest);
622 
623  System.out.println("waitForResourceOwnerAndGrantLoginForm: authorizationRequestUrl:" + authorizationRequestUrl);
624  startSelenium();
625  if (cleanupCookies) {
626  System.out.println("waitForResourceOwnerAndGrantLoginForm: Cleaning cookies");
628  }
629  driver.navigate().to(authorizationRequestUrl);
630 
631  WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
632  WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
633  WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
634 
635  if ((usernameElement == null) || (passwordElement == null) || (loginButton == null)) {
636  return null;
637  }
638 
639  Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
640  String sessionState = null;
641  if (sessionStateCookie != null) {
642  sessionState = sessionStateCookie.getValue();
643  }
644  System.out.println("waitForResourceOwnerAndGrantLoginForm: sessionState:" + sessionState);
645 
646  stopSelenium();
647 
648  showClientUserAgent(authorizeClient);
649 
650  return sessionState;
651  }
String loginFormUsername
Definition: BaseTest.java:88
String loginFormPassword
Definition: BaseTest.java:89
void deleteAllCookies()
Definition: BaseTest.java:661
void stopSelenium()
Definition: BaseTest.java:243
Definition: AuthorizeClient.java:29
void startSelenium()
Definition: BaseTest.java:230
String loginFormLoginButton
Definition: BaseTest.java:90
void setRequest(T request)
Definition: BaseClient.java:68
WebDriver driver
Definition: BaseTest.java:70
String getQueryString()
Definition: AuthorizationRequest.java:486
static void showClientUserAgent(BaseClient client)
Definition: BaseTest.java:783

◆ waitForResourceOwnerAndGrantLoginForm() [2/2]

String org.xdi.oxauth.BaseTest.waitForResourceOwnerAndGrantLoginForm ( String  authorizeUrl,
AuthorizationRequest  authorizationRequest 
)
inlineinherited

Try to open login form (via the user-agent)

657  {
658  return waitForResourceOwnerAndGrantLoginForm(authorizeUrl, authorizationRequest, true);
659  }
String waitForResourceOwnerAndGrantLoginForm(String authorizeUrl, AuthorizationRequest authorizationRequest, boolean cleanupCookies)
Definition: BaseTest.java:616

メンバ詳解

◆ authorizationEndpoint

String org.xdi.oxauth.BaseTest.authorizationEndpoint
protectedinherited

◆ authorizationPageEndpoint

String org.xdi.oxauth.BaseTest.authorizationPageEndpoint
protectedinherited

◆ checkSessionIFrame

String org.xdi.oxauth.BaseTest.checkSessionIFrame
protectedinherited

◆ clientId

String org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.clientId
staticprivate

◆ clientInfoEndpoint

String org.xdi.oxauth.BaseTest.clientInfoEndpoint
protectedinherited

◆ clientSecret

String org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.clientSecret
staticprivate

◆ configurationEndpoint

String org.xdi.oxauth.BaseTest.configurationEndpoint
protectedinherited

◆ driver

WebDriver org.xdi.oxauth.BaseTest.driver
protectedinherited

◆ endSessionEndpoint

String org.xdi.oxauth.BaseTest.endSessionEndpoint
protectedinherited

◆ gluuConfigurationEndpoint

String org.xdi.oxauth.BaseTest.gluuConfigurationEndpoint
protectedinherited

◆ idGenEndpoint

String org.xdi.oxauth.BaseTest.idGenEndpoint
protectedinherited

◆ introspectionEndpoint

String org.xdi.oxauth.BaseTest.introspectionEndpoint
protectedinherited

◆ jwksUri

String org.xdi.oxauth.BaseTest.jwksUri
protectedinherited

◆ registrationEndpoint

String org.xdi.oxauth.BaseTest.registrationEndpoint
protectedinherited

◆ scopeToClaimsMapping

Map<String, List<String> > org.xdi.oxauth.BaseTest.scopeToClaimsMapping
protectedinherited

◆ testData

FileConfiguration org.xdi.oxauth.ConfigurableTest.testData
staticinherited

◆ tokenEndpoint

String org.xdi.oxauth.BaseTest.tokenEndpoint
protectedinherited

◆ url

URI org.xdi.oxauth.ws.rs.TokenRestWebServiceEmbeddedTest.url
private

◆ userInfoEndpoint

String org.xdi.oxauth.BaseTest.userInfoEndpoint
protectedinherited

このクラス詳解は次のファイルから抽出されました: