Class APIStoreRestClient

java.lang.Object
org.wso2.am.integration.test.utils.clients.APIStoreRestClient

public class APIStoreRestClient extends Object
Provides set of method to invoke publisher API
  • Constructor Details

    • APIStoreRestClient

      public APIStoreRestClient(String backendURL)
  • Method Details

    • login

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse login(String userName, String password) throws APIManagerIntegrationTestException
      Login to API store
      Parameters:
      userName - - username to login
      password - - password to login
      Returns:
      - http response
      Throws:
      APIManagerIntegrationTestException - - Throws if login to store fails
    • subscribe

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse subscribe(SubscriptionRequest subscriptionRequest) throws APIManagerIntegrationTestException
      Subscribe to API
      Parameters:
      subscriptionRequest - - subscribe api request
      Returns:
      - http response
      Throws:
      APIManagerIntegrationTestException - - throws if subscription fails
    • subscribe

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse subscribe(SubscriptionRequest subscriptionRequest, String action) throws APIManagerIntegrationTestException
      Subscribe to API using a particular action
      Parameters:
      subscriptionRequest - - subscribe api request
      Returns:
      - http response
      Throws:
      APIManagerIntegrationTestException - - throws if subscription fails
    • generateApplicationKey

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse generateApplicationKey(APPKeyRequestGenerator generateAppKeyRequest) throws APIManagerIntegrationTestException
      Generate token
      Parameters:
      generateAppKeyRequest - - generate api key request
      Returns:
      - http response
      Throws:
      APIManagerIntegrationTestException - - throws if application key generation fails.
    • generateApplicationKeyById

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse generateApplicationKeyById(APPKeyRequestGenerator generateAppKeyRequest) throws APIManagerIntegrationTestException
      Generate token
      Parameters:
      generateAppKeyRequest - - generate api key request
      Returns:
      - http response
      Throws:
      APIManagerIntegrationTestException - - throws if application key generation fails.
    • getAPI

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAPI() throws APIManagerIntegrationTestException
      Get api which are published
      Returns:
      - http response of get API post request
      Throws:
      APIManagerIntegrationTestException - - throws if API information retrieval fails.
    • getSession

      public String getSession()
      Get the current session cookies
      Returns:
      current Cookie
    • generateUserAccessKey

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse generateUserAccessKey(String consumeKey, String consumerSecret, String messageBody, URL tokenEndpointURL) throws APIManagerIntegrationTestException
      Generate user access key
      Parameters:
      consumeKey - - consumer key of user
      consumerSecret - - consumer secret key
      messageBody - - message body
      tokenEndpointURL - - token endpoint url
      Returns:
      - http response of generate access token api call
      Throws:
      APIManagerIntegrationTestException - - throws if generating APIM access token fails
    • getAllPublishedAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllPublishedAPIs() throws APIManagerIntegrationTestException
      Get all published apis
      Returns:
      - http response of get all published apis
      Throws:
      APIManagerIntegrationTestException - - throws if getting publish APIs fails
    • getAllApplications

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllApplications() throws APIManagerIntegrationTestException
      Get all the applications
      Returns:
      - http response of get get all applications
      Throws:
      APIManagerIntegrationTestException - - throws if get all application fails.
    • getApplicationById

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getApplicationById(int applicationId) throws APIManagerIntegrationTestException
      Get application by ID
      Returns:
      - http response of get of application
      Throws:
      APIManagerIntegrationTestException - - throws if get application fails.
    • getPublishedAPIsByApplication

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getPublishedAPIsByApplication(String applicationName) throws APIManagerIntegrationTestException
      Get application details by given name
      Parameters:
      applicationName - - application name
      Returns:
      - http response of get application request
      Throws:
      APIManagerIntegrationTestException - - throws if get application by name fails
    • getPublishedAPIsByApplicationId

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getPublishedAPIsByApplicationId(String applicationName, int applicationId) throws APIManagerIntegrationTestException
      Get application details by given name
      Parameters:
      applicationName - - application name
      Returns:
      - http response of get application request
      Throws:
      APIManagerIntegrationTestException - - throws if get application by name fails
    • addRatingToAPI

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse addRatingToAPI(String apiName, String version, String provider, String rating) throws APIManagerIntegrationTestException
      Add rating into api
      Parameters:
      apiName - - name of api
      version - - api version
      provider - - provider of api
      rating - - api rating
      Returns:
      - http response of add rating request
      Throws:
      APIManagerIntegrationTestException - - throws if rating of api fails
    • removeRatingFromAPI

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse removeRatingFromAPI(String apiName, String version, String provider) throws APIManagerIntegrationTestException
      Remove rating of given API
      Parameters:
      apiName - - name of api
      version - - api version
      provider - - provider of api
      Returns:
      - http response of remove rating request
      Throws:
      APIManagerIntegrationTestException - - Throws if remove API rating fails
    • isRatingActivated

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse isRatingActivated() throws APIManagerIntegrationTestException
      Check if API rating activated
      Returns:
      - http response of rating activated request
      Throws:
      APIManagerIntegrationTestException - - Throws if rating status cannot be retrieved
    • getAllDocumentationOfAPI

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllDocumentationOfAPI(String apiName, String version, String provider) throws APIManagerIntegrationTestException
      Method to retrieve all documents of given api
      Parameters:
      apiName - - name of api
      version - - api version
      provider - - provider of api
      Returns:
      - http response of get all documentation of APIs
      Throws:
      APIManagerIntegrationTestException - - throws if retrieval of API documentation fails
    • getApiEndpointUrls

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getApiEndpointUrls(String apiName, String version, String provider) throws APIManagerIntegrationTestException
      Method to retrieve all endpoint urls
      Throws:
      APIManagerIntegrationTestException
    • getAllPaginatedPublishedAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllPaginatedPublishedAPIs(String tenant, String start, String end) throws APIManagerIntegrationTestException
      Get all paginated published API for a given tenant
      Parameters:
      tenant - - tenant name
      start - - starting index
      end - - closing index
      Returns:
      - http response of paginated published APIs
      Throws:
      APIManagerIntegrationTestException - - throws if paginated apis cannot be retrieved.
    • cleanUpApplicationRegistrationByApplicationId

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse cleanUpApplicationRegistrationByApplicationId(int applicationId, String applicationName) throws APIManagerIntegrationTestException
      Clean up application registration by ID
      Parameters:
      applicationId - - application ID
      applicationName - - application name
      Returns:
      - http response of paginated published APIs
      Throws:
      APIManagerIntegrationTestException - - throws if paginated apis cannot be retrieved.
    • getAllPaginatedPublishedAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllPaginatedPublishedAPIs(String tenant, int start, int end) throws APIManagerIntegrationTestException
      Gell all paginated published apis for a given tenant
      Parameters:
      tenant - - tenant name
      start - - starting index
      end - - ending index
      Throws:
      APIManagerIntegrationTestException
    • getAllPublishedAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllPublishedAPIs(String tenant) throws APIManagerIntegrationTestException
      Get all published APIs for tenant
      Parameters:
      tenant - - tenant name
      Returns:
      - http response of published API
      Throws:
      APIManagerIntegrationTestException - - throws if published API retrieval fails.
    • addApplication

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse addApplication(String application, String tier, String callbackUrl, String description) throws APIManagerIntegrationTestException
      Add application
      Parameters:
      application - - application name
      tier - - throttling tier
      callbackUrl - - callback url
      description - - description of app
      Returns:
      - http response of add application
      Throws:
      APIManagerIntegrationTestException - - if fails to add application
    • addApplicationWithGroup

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse addApplicationWithGroup(String application, String tier, String callbackUrl, String description, String groupId) throws APIManagerIntegrationTestException
      Add application with Group
      Parameters:
      application - - application name
      tier - - throttling tier
      callbackUrl - - callback url
      description - - description of app
      groupId - - group to share
      Returns:
      - http response of add application
      Throws:
      APIManagerIntegrationTestException - - if fails to add application
    • addApplicationWithTokenType

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse addApplicationWithTokenType(String application, String tier, String callbackUrl, String description, String tokenType) throws APIManagerIntegrationTestException
      Add application with token type
      Parameters:
      application - - application name
      tier - - throttling tier
      callbackUrl - - callback url
      description - - description of app
      tokenType - - token type of app (JWT ot DEFAULT)
      Returns:
      - http response of add application
      Throws:
      APIManagerIntegrationTestException - - if fails to add application
    • getApplications

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getApplications() throws APIManagerIntegrationTestException
      Get application
      Returns:
      - http response of get applications
      Throws:
      APIManagerIntegrationTestException - - throws if applications cannot be retrieved.
    • removeApplication

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse removeApplication(String application) throws APIManagerIntegrationTestException
      Delete application
      Parameters:
      application - - application name
      Returns:
      - http response of remove application request
      Throws:
      APIManagerIntegrationTestException - - throws if remove application fails
    • removeApplicationById

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse removeApplicationById(int applicationId) throws APIManagerIntegrationTestException
      Delete application by Id
      Parameters:
      applicationId - - application Id
      Returns:
      - http response of remove application request
      Throws:
      APIManagerIntegrationTestException - - throws if remove application fails
    • updateApplication

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse updateApplication(String applicationOld, String applicationNew, String callbackUrlNew, String descriptionNew, String tier) throws APIManagerIntegrationTestException
      Update given application
      Parameters:
      applicationOld - - application name old
      applicationNew - - new application name
      callbackUrlNew - - call back url
      descriptionNew - - updated description
      tier - - access tier
      Returns:
      - http response of update application
      Throws:
      APIManagerIntegrationTestException - - throws if update application fails
    • updateApplicationById

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse updateApplicationById(int applicationId, String applicationOld, String applicationNew, String callbackUrlNew, String descriptionNew, String tier) throws APIManagerIntegrationTestException
      Update given application
      Parameters:
      applicationOld - - application name old
      applicationNew - - new application name
      callbackUrlNew - - call back url
      descriptionNew - - updated description
      tier - - access tier
      Returns:
      - http response of update application
      Throws:
      APIManagerIntegrationTestException - - throws if update application fails
    • updateClientApplication

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse updateClientApplication(String application, String keyType, String authorizedDomains, String retryAfterFailure, String jsonParams, String callbackUrl) throws APIManagerIntegrationTestException
      Update given Auth application
      Parameters:
      application - auth application name
      keyType - type of the key
      authorizedDomains - authorized domains
      retryAfterFailure - retry after fail
      jsonParams - json parameters for grant type
      callbackUrl - call back url
      Returns:
      Http response of the update request
      Throws:
      APIManagerIntegrationTestException - APIManagerIntegrationTestException - throws if update application fail
    • updateClientApplicationById

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse updateClientApplicationById(int applicationId, String application, String keyType, String authorizedDomains, String retryAfterFailure, String jsonParams, String callbackUrl) throws APIManagerIntegrationTestException
      Update given Auth application
      Parameters:
      application - auth application name
      keyType - type of the key
      authorizedDomains - authorized domains
      retryAfterFailure - retry after fail
      jsonParams - json parameters for grant type
      callbackUrl - call back url
      Returns:
      Http response of the update request
      Throws:
      APIManagerIntegrationTestException - APIManagerIntegrationTestException - throws if update application fail
    • regenerateConsumerSecret

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse regenerateConsumerSecret(String clientId) throws APIManagerIntegrationTestException
      Regenerate consumer secret.
      Parameters:
      clientId - Consumer Key of an application for which consumer secret need to be regenerate.
      Returns:
      Regenerated consumer secret.
      Throws:
      APIManagerIntegrationTestException - Throws if regeneration of consumer secret fail.
    • getAllSubscriptions

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllSubscriptions() throws APIManagerIntegrationTestException
      Get all subscriptions
      Returns:
      - http response of get all subscription request
      Throws:
      APIManagerIntegrationTestException - - throws if get all subscriptions fails
    • getAllSubscriptionsOfApplication

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllSubscriptionsOfApplication() throws APIManagerIntegrationTestException
      Get all subscriptions of Application. This is a method to get the subscription of a given application. As there is no application name is given, then only the subscriptions of first applications are returned.
      Returns:
      - http response of get all subscription request
      Throws:
      APIManagerIntegrationTestException - - throws if get all subscriptions fails
    • getAllSubscriptionsOfApplication

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllSubscriptionsOfApplication(String selectedApplication) throws APIManagerIntegrationTestException
      Get all subscriptions of Application. This is a method to get the subscription of a given application. If no application name is given, then only the subscriptions of first applications are returned.
      Returns:
      - http response of get all subscription request
      Throws:
      APIManagerIntegrationTestException - - throws if get all subscriptions fails
    • getSubscribedAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getSubscribedAPIs(String applicationName) throws APIManagerIntegrationTestException
      Get subscribed Apis by application name
      Parameters:
      applicationName - - Application Name
      Throws:
      APIManagerIntegrationTestException
    • getSubscribedAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getSubscribedAPIs(String applicationName, String domain) throws APIManagerIntegrationTestException
      Get subscribed APIs for the specific Application
      Parameters:
      applicationName - - Name of the Application of API in store
      Returns:
      - HttpResponse - Response with subscribed APIs
      Throws:
      APIManagerIntegrationTestException
    • removeAPISubscription

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse removeAPISubscription(String API, String version, String provider, String applicationId) throws APIManagerIntegrationTestException
      Unsubscribe from API
      Parameters:
      API - - name of api
      version - - api version
      provider - - provider name
      applicationId - - application id
      Returns:
      - http response of unsubscription request
      Throws:
      APIManagerIntegrationTestException - - Throws if unsubscription fails
    • removeAPISubscriptionByApplicationName

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse removeAPISubscriptionByApplicationName(String API, String version, String provider, String applicationName) throws APIManagerIntegrationTestException
      Unsubscribe from API by application name
      Parameters:
      API - - name of api
      version - - api version
      provider - - provider name
      applicationName - - application Name
      Returns:
      - http response of unsubscription request
      Throws:
      APIManagerIntegrationTestException - - Throws if unsubscription fails
    • removeAPISubscriptionByName

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse removeAPISubscriptionByName(String API, String version, String provider, String appName) throws APIManagerIntegrationTestException
      Unsubscribe from API
      Parameters:
      API - - name of api
      version - - api version
      provider - - provider name
      appName - - application name
      Returns:
      - http response of unsubscription request
      Throws:
      APIManagerIntegrationTestException - - Throws if unsubscription fails
    • getAllTags

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAllTags() throws APIManagerIntegrationTestException
      Get all API tags
      Returns:
      - http response of get all api tags
      Throws:
      APIManagerIntegrationTestException - - throws if get all tags fails
    • addComment

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse addComment(String apiName, String version, String provider, String comment) throws APIManagerIntegrationTestException
      Add comment to given API
      Parameters:
      apiName - - name of the api
      version - - api version
      provider - - provider name
      comment - - comment to add
      Returns:
      - http response of add comment
      Throws:
      APIManagerIntegrationTestException - - throws if add comment fails
    • isCommentActivated

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse isCommentActivated() throws APIManagerIntegrationTestException
      Check whether commenting is enabled
      Returns:
      - http response of comment status
      Throws:
      APIManagerIntegrationTestException - - Throws if retrieving comment activation status fails.
    • getRecentlyAddedAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getRecentlyAddedAPIs(String tenant, String limit) throws APIManagerIntegrationTestException
      Get recently added APIs by tenant
      Parameters:
      tenant - - tenant name
      limit - - limit of result set
      Returns:
      - http response of recently added API request
      Throws:
      APIManagerIntegrationTestException - - throws if
    • getAPIPageFilteredWithTags

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAPIPageFilteredWithTags(String apiTag) throws APIManagerIntegrationTestException
      Get the web page with filtered API when click the API Tag link
      Parameters:
      apiTag - - API tag the need ti filter the api.
      Returns:
      HttpResponse - Response that contains the web page with filtered API when click the API Tag link
      Throws:
      APIManagerIntegrationTestException - - Exception throws when check the Authentication and HTTPSClientUtils.sendGetRequest() method call
    • subscribeToAPI

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse subscribeToAPI(SubscriptionRequest subscriptionRequest) throws APIManagerIntegrationTestException
      Subscribe and API. This method return the response of the subscription server REST call.
      Parameters:
      subscriptionRequest - -SubscriptionRequest request instance with API subscription information.
      Returns:
      HttpResponse - Response f the subscription server REST call
      Throws:
      APIManagerIntegrationTestException - - Exception throws when check the Authentication and HTTPSClientUtils.doPost() method call.
    • getAPIListFromStoreAsAnonymousUser

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getAPIListFromStoreAsAnonymousUser(String tenantDomain) throws APIManagerIntegrationTestException
      Throws:
      APIManagerIntegrationTestException
    • logout

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse logout() throws APIManagerIntegrationTestException
      API Store logout
      Throws:
      APIManagerIntegrationTestException
    • signUp

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse signUp(String userName, String password, String firstName, String lastName, String email) throws APIManagerIntegrationTestException
      API Store sign up
      Parameters:
      userName - - store user name
      password - -store password
      firstName - - user first name
      lastName - - user's last name
      email - - user's email
      Returns:
      Throws:
      APIManagerIntegrationTestException
    • signUpforTenant

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse signUpforTenant(String userName, String password, String claims) throws APIManagerIntegrationTestException
      API Store sign up
      Parameters:
      userName - - store user name
      password - -store password
      claims - - tenants claims
      Returns:
      Throws:
      APIManagerIntegrationTestException
    • signUpWithOrganization

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse signUpWithOrganization(String userName, String password, String firstName, String lastName, String email, String organization) throws APIManagerIntegrationTestException
      API Store sign up with organization
      Parameters:
      userName - - store user name
      password - -store password
      firstName - - user first name
      lastName - - user's last name
      email - - user's email
      organization - - user's organization
      Returns:
      Throws:
      APIManagerIntegrationTestException
    • getPrototypedAPI

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getPrototypedAPI(String tenant) throws APIManagerIntegrationTestException
      Get Prototyped APIs in Store
      Returns:
      HttpResponse - Response with APIs which are deployed as a Prototyped APIs
      Throws:
      APIManagerIntegrationTestException
    • searchPaginateAPIs

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse searchPaginateAPIs(String tenant, String start, String end, String searchTerm) throws Exception
      Throws:
      Exception
    • waitForSwaggerDocument

      public void waitForSwaggerDocument(String userName, String apiName, String apiVersion, String expectedResponse, String executionMode) throws IOException, XPathExpressionException
      Wait for swagger document until its updated.
      Parameters:
      userName - - Name of the api provider
      apiName - - API Name
      apiVersion - - API Version
      expectedResponse - - Expected response of the API
      executionMode - - Mode of the test execution (Standalone or Platform)
      Throws:
      IOException - - Throws if Swagger document cannot be found
      XPathExpressionException - - Throws if Swagger document cannot be found
    • getSwaggerDocument

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getSwaggerDocument(String userName, String apiName, String apiVersion, String executionMode) throws APIManagerIntegrationTestException
      This method will return swagger document of given api name and version
      Parameters:
      userName - - User who request the swagger document
      apiName - - Name of the API
      apiVersion - - Version of the API
      executionMode - - Mode of the test execution (Standalone or Platform)
      Returns:
      - HTTP Response of the GET swagger document request
      Throws:
      APIManagerIntegrationTestException - - Throws if swagger document GET request fails
    • getApplicationPage

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse getApplicationPage() throws APIManagerIntegrationTestException
      Get application page
      Returns:
      - http response of get application
      Throws:
      APIManagerIntegrationTestException - - if fails to get application page
    • generateSDKUpdated

      public org.apache.http.HttpResponse generateSDKUpdated(String sdkLanguage, String apiName, String apiVersion, String apiProvider, String tenant) throws APIManagerIntegrationTestException
      Generate SDK for a given programming language
      Parameters:
      sdkLanguage - programming language for the SDK
      apiName - name of the API
      apiVersion - version of the API
      apiProvider - provider of the API
      Returns:
      org.apache.http.HttpResponse for the SDK generation
      Throws:
      APIManagerIntegrationTestException - if failed to generate the SDK
    • changePassword

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse changePassword(String username, String currentPassword, String newPassword) throws APIManagerIntegrationTestException
      Change password of the user
      Parameters:
      username - username of the user
      currentPassword - current password of the user
      newPassword - new password of the user
      Returns:
      Throws:
      APIManagerIntegrationTestException - if failed to change password
    • addApplicationWithCustomAttributes

      public org.wso2.carbon.automation.test.utils.http.client.HttpResponse addApplicationWithCustomAttributes(String application, String tier, String callbackUrl, String description, String applicationAttributes) throws APIManagerIntegrationTestException
      Add application with custom attributes
      Parameters:
      application - - application name
      tier - - throttling tier
      callbackUrl - - callback url
      description - - description of app
      applicationAttributes - - Json string of custom attributes defined by user
      Returns:
      - http response of add application
      Throws:
      APIManagerIntegrationTestException - - if fails to add application