Class APIMTestCaseUtils

java.lang.Object
org.wso2.am.integration.test.utils.generic.APIMTestCaseUtils

public class APIMTestCaseUtils extends Object
  • Constructor Details

    • APIMTestCaseUtils

      public APIMTestCaseUtils()
  • Method Details

    • loadResource

      public static org.apache.axiom.om.OMElement loadResource(String path) throws FileNotFoundException, XMLStreamException
      Loads the specified resource from the classpath and returns its content as an OMElement.
      Parameters:
      path - A relative path to the resource file
      Returns:
      An OMElement containing the resource content
      Throws:
      FileNotFoundException
      XMLStreamException
    • updateSynapseConfiguration

      public static void updateSynapseConfiguration(org.apache.axiom.om.OMElement synapseConfig, String backendURL, String sessionCookie) throws Exception
      Parameters:
      synapseConfig - - Synapse configuration to be updated
      backendURL - - backend URL of the gateway server
      sessionCookie - - session cookie of user login
      Throws:
      Exception - - Throws if update fails
    • addEndpoint

      public static void addEndpoint(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement endpointConfig) throws Exception
      Throws:
      Exception
    • addLocalEntry

      public static void addLocalEntry(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement localEntryConfig) throws Exception
      Throws:
      Exception
    • addSequence

      public static void addSequence(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement sequenceConfig) throws Exception
      Throws:
      Exception
    • addSequenceTemplate

      public static void addSequenceTemplate(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement sequenceTemplate) throws RemoteException
      Throws:
      RemoteException
    • addEndpointTemplate

      public static void addEndpointTemplate(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement endpointTemplate) throws RemoteException
      Throws:
      RemoteException
    • addAPI

      public static void addAPI(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement api) throws RemoteException, org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      Throws:
      RemoteException
      org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
    • addPriorityExecutor

      public static void addPriorityExecutor(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement priorityExecutor) throws RemoteException
      Throws:
      RemoteException
    • addScheduleTask

      public static void addScheduleTask(String backEndUrl, String sessionCookie, org.apache.axiom.om.OMElement taskDescription) throws org.wso2.carbon.task.stub.TaskManagementException, RemoteException
      Throws:
      org.wso2.carbon.task.stub.TaskManagementException
      RemoteException
    • isEndpointDeployed

      public static boolean isEndpointDeployed(String backEndUrl, String sessionCookie, String endpointName) throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException, RemoteException
      Throws:
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      RemoteException
    • isSequenceDeployed

      public static boolean isSequenceDeployed(String backEndUrl, String sessionCookie, String sequenceName) throws org.wso2.carbon.sequences.stub.types.SequenceEditorException, RemoteException
      Throws:
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      RemoteException
    • isSequenceTemplateDeployed

      public static boolean isSequenceTemplateDeployed(String backEndUrl, String sessionCookie, String sequenceTemplateName) throws RemoteException
      Throws:
      RemoteException
    • isEndpointTemplateDeployed

      public static boolean isEndpointTemplateDeployed(String backEndUrl, String sessionCookie, String endpointTemplateName) throws RemoteException
      Throws:
      RemoteException
    • isApiDeployed

      public static boolean isApiDeployed(String backEndUrl, String sessionCookie, String apiName) throws RemoteException, org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      Throws:
      RemoteException
      org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
    • isPriorityExecutorDeployed

      public static boolean isPriorityExecutorDeployed(String backEndUrl, String sessionCookie, String executorName) throws RemoteException
      Throws:
      RemoteException
    • isScheduleTaskDeployed

      public static boolean isScheduleTaskDeployed(String backEndUrl, String sessionCookie, String taskName) throws RemoteException, org.wso2.carbon.task.stub.TaskManagementException
      Throws:
      RemoteException
      org.wso2.carbon.task.stub.TaskManagementException
    • isLocalEntryExist

      public static boolean isLocalEntryExist(String backEndUrl, String sessionCookie, String localEntryName) throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException, RemoteException
      Throws:
      org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
      RemoteException
    • isSequenceExist

      public static boolean isSequenceExist(String backEndUrl, String sessionCookie, String sequenceName) throws org.wso2.carbon.sequences.stub.types.SequenceEditorException, RemoteException
      Throws:
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      RemoteException
    • isEndpointExist

      public static boolean isEndpointExist(String backEndUrl, String sessionCookie, String endpointName) throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException, RemoteException
      Throws:
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      RemoteException
    • isSequenceTemplateExist

      public static boolean isSequenceTemplateExist(String backEndUrl, String sessionCookie, String sequenceTemplate) throws RemoteException
      Throws:
      RemoteException
    • isEndpointTemplateExist

      public static boolean isEndpointTemplateExist(String backEndUrl, String sessionCookie, String endpointTemplate) throws RemoteException
      Throws:
      RemoteException
    • isApiExist

      public static boolean isApiExist(String backEndUrl, String sessionCookie, String apiName) throws RemoteException, org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      Throws:
      RemoteException
      org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
    • isPriorityExecutorExist

      public static boolean isPriorityExecutorExist(String backEndUrl, String sessionCookie, String priorityExecutorName) throws RemoteException
      Throws:
      RemoteException
    • isScheduleTaskExist

      public static boolean isScheduleTaskExist(String backEndUrl, String sessionCookie, String taskName) throws RemoteException, org.wso2.carbon.task.stub.TaskManagementException
      Throws:
      RemoteException
      org.wso2.carbon.task.stub.TaskManagementException
    • deleteLocalEntry

      public static void deleteLocalEntry(String backEndUrl, String sessionCookie, String localEntryName) throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException, RemoteException
      Throws:
      org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
      RemoteException
    • deleteEndpoint

      public static void deleteEndpoint(String backEndUrl, String sessionCookie, String endpointName) throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException, RemoteException
      Throws:
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      RemoteException
    • deleteSequence

      public static void deleteSequence(String backEndUrl, String sessionCookie, String sequenceName) throws org.wso2.carbon.sequences.stub.types.SequenceEditorException, RemoteException
      Throws:
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      RemoteException
    • deleteEndpointTemplate

      public static void deleteEndpointTemplate(String backEndUrl, String sessionCookie, String endpointTemplate) throws RemoteException, org.wso2.carbon.sequences.stub.types.SequenceEditorException, org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      Throws:
      RemoteException
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
    • deleteSequenceTemplate

      public static void deleteSequenceTemplate(String backEndUrl, String sessionCookie, String sequenceTemplateName) throws RemoteException, org.wso2.carbon.sequences.stub.types.SequenceEditorException, org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      Throws:
      RemoteException
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
    • deleteApi

      public static void deleteApi(String backEndUrl, String sessionCookie, String apiName) throws RemoteException, org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      Throws:
      RemoteException
      org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
    • deletePriorityExecutor

      public static void deletePriorityExecutor(String backEndUrl, String sessionCookie, String executorName) throws RemoteException
      Throws:
      RemoteException
    • deleteScheduleTask

      public static void deleteScheduleTask(String backEndUrl, String sessionCookie, String taskName, String group) throws org.wso2.carbon.task.stub.TaskManagementException, RemoteException
      Throws:
      org.wso2.carbon.task.stub.TaskManagementException
      RemoteException
    • isMessageProcessorUnDeployed

      public static boolean isMessageProcessorUnDeployed(String backEndUrl, String sessionCookie, String messageProcessorName) throws org.wso2.carbon.sequences.stub.types.SequenceEditorException, RemoteException
      Throws:
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      RemoteException
    • isLocalEntryDeployed

      public static boolean isLocalEntryDeployed(String backEndUrl, String sessionCookie, String localEntryName) throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException, RemoteException
      Throws:
      org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
      RemoteException
    • isLocalEntryUnDeployed

      public static boolean isLocalEntryUnDeployed(String backEndUrl, String sessionCookie, String localEntryName) throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException, RemoteException
      Throws:
      org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
      RemoteException
    • isSequenceUnDeployed

      public static boolean isSequenceUnDeployed(String backEndUrl, String sessionCookie, String sequenceName) throws org.wso2.carbon.sequences.stub.types.SequenceEditorException, RemoteException
      Throws:
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      RemoteException
    • isEndpointUnDeployed

      public static boolean isEndpointUnDeployed(String backEndUrl, String sessionCookie, String endpointName) throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException, RemoteException
      Throws:
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      RemoteException
    • isEndpointTemplateUnDeployed

      public static boolean isEndpointTemplateUnDeployed(String backEndUrl, String sessionCookie, String endpointTemplateName) throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException, RemoteException
      Throws:
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      RemoteException
    • isSequenceTemplateUnDeployed

      public static boolean isSequenceTemplateUnDeployed(String backEndUrl, String sessionCookie, String sequenceTemplateName) throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException, RemoteException
      Throws:
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      RemoteException
    • isApiUnDeployed

      public static boolean isApiUnDeployed(String backEndUrl, String sessionCookie, String apiName) throws RemoteException, org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      Throws:
      RemoteException
      org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
    • isPriorityExecutorUnDeployed

      public static boolean isPriorityExecutorUnDeployed(String backEndUrl, String sessionCookie, String executorName) throws RemoteException
      Throws:
      RemoteException
    • isScheduleTaskUnDeployed

      public static boolean isScheduleTaskUnDeployed(String backEndUrl, String sessionCookie, String taskName) throws RemoteException, org.wso2.carbon.task.stub.TaskManagementException
      Throws:
      RemoteException
      org.wso2.carbon.task.stub.TaskManagementException
    • verifySynapseDeployment

      public static void verifySynapseDeployment(org.apache.axiom.om.OMElement synapseConfig, String backendURL, String sessionCookie) throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException, RemoteException, org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException, org.wso2.carbon.sequences.stub.types.SequenceEditorException, org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      Throws:
      org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
      RemoteException
      org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      org.wso2.carbon.sequences.stub.types.SequenceEditorException
      org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
    • getAPIBeanFromHttpResponse

      public static APIBean getAPIBeanFromHttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse httpResponse) throws APIManagerIntegrationTestException
      create API bean object from response
      Parameters:
      httpResponse - - HTTP response
      Returns:
      - APIBean instance
      Throws:
      APIManagerIntegrationTestException
    • sendGetRequest

      public static void sendGetRequest(String url, String accessToken) throws XPathExpressionException, IOException
      Throws:
      XPathExpressionException
      IOException
    • getDecodedJWT

      public static String getDecodedJWT(String jwt) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • getJWTAssertion

      public static String getJWTAssertion(String jwt) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • isJwtSignatureValid

      public static boolean isJwtSignatureValid(String jwtAssertion, byte[] jwtSignature, String jsonHeader) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • getDecodedJWTHeader

      public static String getDecodedJWTHeader(String jwt) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • getDecodedJWTSignature

      public static byte[] getDecodedJWTSignature(String jwt) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • getDecodedURLSafeJWTSignature

      public static byte[] getDecodedURLSafeJWTSignature(String jwt) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • decode

      public static byte[] decode(String stringToBeDecodedArg) throws UnsupportedEncodingException
      This method is used to base64Url-decode a base64Url-encoded string
      Parameters:
      stringToBeDecodedArg - - The base64Url encoded string to be decoded
      Returns:
      - The base64Url decoded string
      Throws:
      UnsupportedEncodingException
    • getDecodedURLSafeJWT

      public static String getDecodedURLSafeJWT(String jwt) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • getDecodedURLSafeJWTHeader

      public static String getDecodedURLSafeJWTHeader(String jwt) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • getAPIIdentifierListFromHttpResponse

      public static List<org.wso2.carbon.apimgt.api.model.APIIdentifier> getAPIIdentifierListFromHttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse httpResponse) throws APIManagerIntegrationTestException
      Get the API information from the response object as Lost of APIIdentifier
      Parameters:
      httpResponse - Response that contains the API information
      Returns:
      List of APIIdentifier
      Throws:
      org.json.JSONException
      APIManagerIntegrationTestException
    • getAPIIdentifierListFromHttpResponse

      public static List<org.wso2.carbon.apimgt.api.model.APIIdentifier> getAPIIdentifierListFromHttpResponse(APIListDTO apiListDTO)
      Parameters:
      apiListDTO -
      Returns:
      Throws:
      APIManagerIntegrationTestException
    • getAPIIdentifierListFromHttpResponse

      public static List<org.wso2.carbon.apimgt.api.model.APIIdentifier> getAPIIdentifierListFromHttpResponse(APIListDTO apiListDTO)
      Parameters:
      apiListDTO -
      Returns:
      Throws:
      APIManagerIntegrationTestException
    • isAPIAvailable

      public static boolean isAPIAvailable(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifierToCheck, List<org.wso2.carbon.apimgt.api.model.APIIdentifier> apiIdentifierList)
      Check the given API is available in the APIIdentifier List. it will match for API Name,API Version and API Provider
      Parameters:
      apiIdentifierToCheck - - API identifier to verify
      apiIdentifierList - - API identifier list
      Returns:
      - Status of API availability
    • getPayloadForPasswordGrant

      public static String getPayloadForPasswordGrant(String username, String password)
      Get the json payload required for getting an access token using the password grant-type
      Parameters:
      username - - The username of the user (required)
      password - - The password of the user (required)
      Returns:
      - The json payload. Sample: "grant_type=passwordinvalid input: '&username'=userinvalid input: '&password'=pass"
    • isAPIAvailable

      public static boolean isAPIAvailable(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, APIListDTO apiListDTO)
      Check the given API is available in the APIIdentifier List. it will match for API Name,API Version and API Provider
      Parameters:
      apiIdentifier - - API DTO to verify
      apiListDTO - - API Info DTO list
      Returns:
      - Status of API availability
    • isAPIAvailableInStore

      public static boolean isAPIAvailableInStore(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier, APIListDTO apiListDTO)
      Check the given API is available in the APIIdentifier List. it will match for API Name,API Version and API Provider
      Parameters:
      apiIdentifier - - API DTO to verify
      apiListDTO - - API Info DTO list
      Returns:
      - Status of API availability
    • encodeCredentials

      public static String encodeCredentials(String user, char[] pass)
      get the base64 encoded username and password
      Parameters:
      user - username
      pass - password
      Returns:
      encoded basic auth, as string
    • getTempSwaggerFileWithContent

      public static File getTempSwaggerFileWithContent(String swagger) throws Exception
      Throws:
      Exception