org.wso2.carbon.automation.engine.context.beans.User Java Examples
The following examples show how to use
org.wso2.carbon.automation.engine.context.beans.User.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidSenseEnrollment.java From product-iots with Apache License 2.0 | 6 votes |
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP}) public void initTest() throws Exception { super.init(userMode); User currentUser = getAutomationContext().getContextTenant().getContextUser(); byte[] bytesEncoded = Base64 .encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes()); String encoded = new String(bytesEncoded); String auth_string = "Basic " + encoded; String anaytics_https_url = automationContext.getContextUrls().getWebAppURLHttps() .replace("9443", String.valueOf(Constants.HTTPS_ANALYTICS_PORT)) .replace("/t/" + automationContext.getContextTenant().getDomain(), "") + "/"; this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); this.analyticsClient = new RestClient(anaytics_https_url, Constants.APPLICATION_JSON, auth_string); if (this.userMode == TestUserMode.TENANT_ADMIN) { HttpResponse response = client .post(Constants.AndroidSenseEnrollment.ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT, ""); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); } }
Example #2
Source File: SecureServiceClient.java From product-ei with Apache License 2.0 | 6 votes |
public OMElement sendSecuredStockQuoteRequest(User userInfo, String trpUrl, String symbol ,boolean teant) throws Exception { boolean isTenant = teant; String keyStorePath; String userCertAlias; String encryptionUser; String keyStorePassword; if (isTenant) { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "security" + File.separator + "keystore" + File.separator + "wso2carbon.jks";// need to include tenants certificate userCertAlias = "wso2carbon"; encryptionUser = "wso2carbon"; keyStorePassword = "wso2carbon"; } else { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "keystores" + File.separator + "products" + File.separator + "wso2carbon.jks"; userCertAlias = "wso2carbon"; encryptionUser = "wso2carbon"; keyStorePassword = "wso2carbon"; } return secureClient.sendReceive(userInfo.getUserName(), userInfo.getPassword(), trpUrl, "getQuote" , createSimpleStockQuoteRequest(symbol), null,userCertAlias, encryptionUser, keyStorePath, keyStorePassword); }
Example #3
Source File: SecureServiceClient.java From micro-integrator with Apache License 2.0 | 5 votes |
public OMElement sendSecuredRequest(User userInfo, String trpUrl, int securityPolicyId, OMElement payload, String action) throws Exception { //todo isTenat boolean isTenant = false; String policyPath = TestConfigurationProvider.getSecurityPolicyLocation() + File.separator + "scenario" + securityPolicyId + "-policy.xml"; String keyStorePath; String userCertAlias; String encryptionUser; String keyStorePassword; if (isTenant) { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "security" + File.separator + "keystore" + File.separator + "clients.jks"; userCertAlias = "clients"; encryptionUser = "service"; keyStorePassword = "automation"; } else { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "keystores" + File.separator + "products" + File.separator + "wso2carbon.jks"; userCertAlias = "wso2carbon"; encryptionUser = "wso2carbon"; keyStorePassword = "wso2carbon"; } return secureClient .sendReceive(userInfo.getUserName(), userInfo.getPassword(), trpUrl, action, payload, policyPath, userCertAlias, encryptionUser, keyStorePath, keyStorePassword); }
Example #4
Source File: StratosTestServerManager.java From attic-stratos with Apache License 2.0 | 5 votes |
public synchronized void restartGracefully() throws AutomationFrameworkException { try { int time = defaultHttpsPort + this.portOffset; String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl() .replaceAll("(:\\d+)", ":" + time); User e = this.automationContext.getSuperTenant().getTenantAdmin(); ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, e.getUserName(), e.getPassword()); } catch (XPathExpressionException var5) { throw new AutomationFrameworkException("restart failed", var5); } long time1 = System.currentTimeMillis() + 300000L; while (!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time1) { ; } time1 = System.currentTimeMillis(); while (System.currentTimeMillis() < time1 + 5000L) { ; } try { ClientConnectionUtil.waitForPort( Integer.parseInt((String) this.automationContext.getInstance().getPorts().get("https")), RESTART_TIMEOUT, true, (String) this.automationContext.getInstance().getHosts().get("default")); ClientConnectionUtil.waitForLogin(this.automationContext); } catch (XPathExpressionException var4) { throw new AutomationFrameworkException("Connection attempt to carbon server failed", var4); } }
Example #5
Source File: CEPIntegrationTest.java From product-cep with Apache License 2.0 | 5 votes |
/** * This method will return current user loggedIn * * @return user - the tenant user * @throws XPathExpressionException */ public User getCurrentUserInfo() throws XPathExpressionException { if (userInfo == null) { userInfo = getCurrentTenantInfo().getContextUser(); } return userInfo; }
Example #6
Source File: TestBase.java From product-iots with Apache License 2.0 | 5 votes |
protected void init(TestUserMode userMode) throws Exception { automationContext = new AutomationContext(Constants.AUTOMATION_CONTEXT, userMode); String tenantDomain = automationContext.getContextTenant().getDomain(); backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps().replace("9443", String.valueOf(Constants .HTTPS_GATEWAY_PORT)).replace("/t/" + tenantDomain , ""); backendHTTPURL = automationContext.getContextUrls().getWebAppURL().replace("9763", String.valueOf(Constants .HTTP_GATEWAY_PORT)).replace("/t/" + tenantDomain , ""); User currentUser = getAutomationContext().getContextTenant().getContextUser(); byte[] bytesEncoded = Base64 .encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes()); String encoded = new String(bytesEncoded); accessToken = OAuthUtil.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(), currentUser.getPassword()); accessTokenString = "Bearer " + accessToken; }
Example #7
Source File: CarbonServerManagerExtension.java From product-iots with Apache License 2.0 | 5 votes |
public synchronized void restartGracefully() throws AutomationFrameworkException { try { int httpsPort = defaultHttpsPort + this.portOffset; String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort); User superUser = this.automationContext.getSuperTenant().getTenantAdmin(); ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, superUser.getUserName(), superUser.getPassword()); } catch (XPathExpressionException var5) { throw new AutomationFrameworkException("restart failed", var5); } long time = System.currentTimeMillis() + 300000L; // while(!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) { // ; // } time = System.currentTimeMillis(); while(System.currentTimeMillis() < time + 5000L) { ; } try { ClientConnectionUtil.waitForPort(Integer.parseInt((String)this.automationContext.getInstance().getPorts().get("https")), (String)this.automationContext.getInstance().getHosts().get("default")); ClientConnectionUtil.waitForLogin(this.automationContext); } catch (XPathExpressionException var4) { throw new AutomationFrameworkException("Connection attempt to carbon server failed", var4); } }
Example #8
Source File: NonAdminUserCreationTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@BeforeTest(alwaysRun = true) public void addNonAdminUser() throws Exception { AutomationContext esbContext = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN); String sessionCookie = new LoginLogoutClient(esbContext).login(); ResourceAdminServiceClient resourceAdmin = new ResourceAdminServiceClient(esbContext.getContextUrls().getBackEndUrl(), sessionCookie); UserManagementClient userManagementClient = new UserManagementClient(esbContext.getContextUrls().getBackEndUrl(), sessionCookie); //done this change due to a bug in UM - please refer to carbon dev mail // "G-Reg integration test failures due to user mgt issue." String[] permissions = {"/permission/admin/configure/", "/permission/admin/login", "/permission/admin/manage/", "/permission/admin/monitor", "/permission/protected"}; if (!userManagementClient.roleNameExists(ROLE_NAME)) { userManagementClient.addRole(ROLE_NAME, null, permissions); resourceAdmin.addResourcePermission("/", ROLE_NAME, "3", "1"); resourceAdmin.addResourcePermission("/", ROLE_NAME, "2", "1"); resourceAdmin.addResourcePermission("/", ROLE_NAME, "4", "1"); resourceAdmin.addResourcePermission("/", ROLE_NAME, "5", "1"); } userManagementClient.addUser("nonadminuser", "password", new String[]{ROLE_NAME}, null); //check user creation nonAdminUser = new User(); nonAdminUser.setUserName("nonadminuser"); nonAdminUser.setPassword("password"); }
Example #9
Source File: SecureServiceClient.java From product-ei with Apache License 2.0 | 5 votes |
public OMElement sendSecuredRequest(User userInfo, String trpUrl, int securityPolicyId, OMElement payload, String action) throws Exception { //todo isTenat boolean isTenant = false; String policyPath = TestConfigurationProvider.getSecurityPolicyLocation() + File.separator + "scenario" + securityPolicyId + "-policy.xml"; String keyStorePath; String userCertAlias; String encryptionUser; String keyStorePassword; if (isTenant) { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "security" + File.separator + "keystore" + File.separator + "clients.jks"; userCertAlias = "clients"; encryptionUser = "service"; keyStorePassword = "automation"; } else { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "keystores" + File.separator + "products" + File.separator + "wso2carbon.jks"; userCertAlias = "wso2carbon"; encryptionUser = "wso2carbon"; keyStorePassword = "wso2carbon"; } return secureClient.sendReceive(userInfo.getUserName(), userInfo.getPassword(), trpUrl, action , payload, policyPath, userCertAlias, encryptionUser, keyStorePath, keyStorePassword); }
Example #10
Source File: TopicPermissionTestCase.java From product-ei with Apache License 2.0 | 5 votes |
/** * Creates a topic by giving topic creation rights to the user. * 1. User is in a role with no permissions. * 2. Admin gives permissions to the role to create topics and for logging in. * 3. User creates a topic. * 4. Validates whether topic is created. * * @throws XPathExpressionException * @throws IOException * @throws UserAdminUserAdminException */ @Test(groups = {"wso2.mb", "topic"}) public void createTopicPermissionTestCase() throws XPathExpressionException, IOException, UserAdminUserAdminException { String topicName = "topicCreationPermission"; AutomationContext authAutomationContext = new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, "topicAuthUser"); User contextUser = authAutomationContext.getContextTenant().getContextUser(); String[] createPermissionUser = new String[]{contextUser.getUserNameWithoutDomain()}; // Logging into user management as admin UserManagementClient userManagementClient = new UserManagementClient(super.backendURL, "admin", "admin"); // Removing admin permission for user userManagementClient.updateUserListOfRole(FrameworkConstants.ADMIN_ROLE, null, createPermissionUser); // Adding roles along with users userManagementClient .addRole(CREATE_TOPIC_PERMISSION_ROLE, createPermissionUser, new String[]{ADD_TOPIC_PERMISSION, LOGIN_PERMISSION}); driver.get(getLoginURL()); LoginPage loginPage = new LoginPage(driver); // Logging in to the the management console HomePage homePage = loginPage.loginAs(contextUser.getUserNameWithoutDomain(), contextUser.getPassword()); TopicAddPage topicAddPage = homePage.getTopicAddPage("home.mb.topics.add.without.queue.xpath"); // Creating a topic by the user and check whether valid dialog pop up is shown Assert.assertEquals(topicAddPage.addTopic(topicName), true); TopicsBrowsePage topicsBrowsePage = homePage.getTopicsBrowsePage("home.mb.topics.browse.without.queue.xpath"); // Checks whether topic is created in the browsing page Assert.assertEquals(topicsBrowsePage.isTopicPresent(topicName), true); }
Example #11
Source File: NonAdminUserCreationTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@BeforeTest(alwaysRun = true) public void addNonAdminUser() throws Exception { AutomationContext esbContext = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN); String sessionCookie = new LoginLogoutClient(esbContext).login(); ResourceAdminServiceClient resourceAdmin = new ResourceAdminServiceClient( esbContext.getContextUrls().getBackEndUrl(), sessionCookie); UserManagementClient userManagementClient = new UserManagementClient( esbContext.getContextUrls().getBackEndUrl(), sessionCookie); //done this change due to a bug in UM - please refer to carbon dev mail // "G-Reg integration test failures due to user mgt issue." String[] permissions = { "/permission/admin/configure/", "/permission/admin/login", "/permission/admin/manage/", "/permission/admin/monitor", "/permission/protected" }; if (!userManagementClient.roleNameExists(ROLE_NAME)) { userManagementClient.addRole(ROLE_NAME, null, permissions); resourceAdmin.addResourcePermission("/", ROLE_NAME, "3", "1"); resourceAdmin.addResourcePermission("/", ROLE_NAME, "2", "1"); resourceAdmin.addResourcePermission("/", ROLE_NAME, "4", "1"); resourceAdmin.addResourcePermission("/", ROLE_NAME, "5", "1"); } userManagementClient.addUser("nonadminuser", "password", new String[] { ROLE_NAME }, null); //check user creation nonAdminUser = new User(); nonAdminUser.setUserName("nonadminuser"); nonAdminUser.setPassword("password"); }
Example #12
Source File: SecureServiceClient.java From micro-integrator with Apache License 2.0 | 5 votes |
public OMElement sendSecuredStockQuoteRequest(User userInfo, String trpUrl, String symbol, boolean teant) throws Exception { boolean isTenant = teant; String keyStorePath; String userCertAlias; String encryptionUser; String keyStorePassword; if (isTenant) { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "security" + File.separator + "keystore" + File.separator + "wso2carbon.jks";// need to include tenants certificate userCertAlias = "wso2carbon"; encryptionUser = "wso2carbon"; keyStorePassword = "wso2carbon"; } else { keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "keystores" + File.separator + "products" + File.separator + "wso2carbon.jks"; userCertAlias = "wso2carbon"; encryptionUser = "wso2carbon"; keyStorePassword = "wso2carbon"; } return secureClient.sendReceive(userInfo.getUserName(), userInfo.getPassword(), trpUrl, "getQuote", createSimpleStockQuoteRequest(symbol), null, userCertAlias, encryptionUser, keyStorePath, keyStorePassword); }
Example #13
Source File: TopicUserAuthorizationTestCase.java From product-ei with Apache License 2.0 | 4 votes |
/** * Runs a test case where a consumer and publisher is created and published with a given user * key from the automation.xml. Subscriber get unsubscribe after receiving expected message count. * * @param userKey The user key mentioned in the automation.xml for a specific user. * @param destinationName The destination name of the topic. * @throws XPathExpressionException * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientConfigurationException * @throws IOException * @throws javax.jms.JMSException * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientException * @throws javax.naming.NamingException */ private void createPublishSubscribeAndUnsubscribeFromUser(String userKey, String destinationName) throws XPathExpressionException, AndesClientConfigurationException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 10L; long expectedCount = 10L; AutomationContext userAutomationContext = new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, userKey); User contextUser = userAutomationContext.getContextTenant().getContextUser(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration( getAMQPPort(), contextUser.getUserNameWithoutDomain(), contextUser.getPassword(), ExchangeType.TOPIC, destinationName); consumerConfig.setMaximumMessagesToReceived(expectedCount); consumerConfig.setUnSubscribeAfterEachMessageCount(expectedCount); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), contextUser.getUserNameWithoutDomain(), contextUser.getPassword(), ExchangeType.TOPIC, destinationName); publisherConfig.setNumberOfMessagesToSend(sendCount); // Creating clients AndesClient consumerClient = new AndesClient(consumerConfig, true); consumerClient.startClient(); AndesClient publisherClient = new AndesClient(publisherConfig, true); publisherClient.startClient(); AndesClientUtils .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); // Evaluating Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " + "failed for user : " + contextUser.getUserNameWithoutDomain()); Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " + "receiving failed for user : " + contextUser.getUserNameWithoutDomain()); }
Example #14
Source File: SubTopicUserAuthorizationTestCase.java From product-ei with Apache License 2.0 | 4 votes |
/** * Runs a test case where a consumer and publisher is created and published with a given user * key from the automation.xml. * * @param topicConsumeUser user defined in automation.xml for consume from a topic. * @param topicPublishUser user defined in automation.xml for publish to a topic. * @param destinationName topic destination. * @throws XPathExpressionException * @throws AndesClientConfigurationException * @throws IOException * @throws JMSException * @throws AndesClientException * @throws NamingException */ private void createPublishAndSubscribeFromUsers(String topicConsumeUser, String topicPublishUser, String destinationName) throws XPathExpressionException, AndesClientConfigurationException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 100L; long expectedCount = 100L; // get context for topic consume user AutomationContext topicConsumeUserAutomationContext = new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, topicConsumeUser); User consumeUser = topicConsumeUserAutomationContext.getContextTenant().getContextUser(); // get context for topic publisher user AutomationContext topicPublishUserAutomationContext = new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, topicPublishUser); User publishUser = topicPublishUserAutomationContext.getContextTenant().getContextUser(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration( getAMQPPort(), consumeUser.getUserNameWithoutDomain(), consumeUser.getPassword(), ExchangeType.TOPIC, destinationName); consumerConfig.setMaximumMessagesToReceived(expectedCount); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), publishUser.getUserNameWithoutDomain(), publishUser.getPassword(), ExchangeType.TOPIC, destinationName); publisherConfig.setNumberOfMessagesToSend(sendCount); // Creating clients AndesClient consumerClient = new AndesClient(consumerConfig, true); consumerClient.startClient(); AndesClient publisherClient = new AndesClient(publisherConfig, true); publisherClient.startClient(); AndesClientUtils .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); // Evaluating Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " + "failed for user : " + consumeUser.getUserNameWithoutDomain()); Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " + "receiving failed for user : " + publishUser.getUserNameWithoutDomain()); }
Example #15
Source File: QueueUserAuthorizationTestCase.java From product-ei with Apache License 2.0 | 4 votes |
/** * Runs a test case where a consumer and publisher is created and published with a given user * key from the automation.xml. * * @param userKey The user key mentioned in the automation.xml for a specific user. * @param destinationName The destination name of the queue. * @throws XPathExpressionException * @throws AndesClientConfigurationException * @throws IOException * @throws JMSException * @throws AndesClientException * @throws NamingException */ private void createPublishAndSubscribeFromUser(String userKey, String destinationName) throws XPathExpressionException, AndesClientConfigurationException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 10L; long expectedCount = 10L; AutomationContext userAutomationContext = new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, userKey); User contextUser = userAutomationContext.getContextTenant().getContextUser(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(getAMQPPort(), contextUser.getUserNameWithoutDomain(), contextUser.getPassword(), ExchangeType.QUEUE, destinationName); consumerConfig.setMaximumMessagesToReceived(expectedCount); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(getAMQPPort(), contextUser.getUserNameWithoutDomain(), contextUser.getPassword(), ExchangeType.QUEUE, destinationName); publisherConfig.setNumberOfMessagesToSend(sendCount); // Creating clients AndesClient consumerClient = new AndesClient(consumerConfig, true); consumerClient.startClient(); AndesClient publisherClient = new AndesClient(publisherConfig, true); publisherClient.startClient(); AndesClientUtils .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); // Evaluating Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " + "failed for user : " + contextUser.getUserNameWithoutDomain()); Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " + "receiving failed for user : " + contextUser.getUserNameWithoutDomain()); }
Example #16
Source File: DtxPrepareNegativeTestCase.java From product-ei with Apache License 2.0 | 4 votes |
/** * Tests if preparing a DTX branch with publishing permission issues throws an error */ @Test(groups = { "wso2.mb", "dtx" }, expectedExceptions = XAException.class) public void prepareDtxBranchWithNoRoutesIssue() throws NamingException, JMSException, XAException, XPathExpressionException { String queueName = "DtxPrepareTestCasePrepareDtxBranchWithNoRoutesIssues"; User adminUser = getSuperTenantAdminUser(); InitialContext adminInitialContext = JMSClientHelper.createInitialContextBuilder(adminUser.getUserNameWithoutDomain(), adminUser.getPassword(), getBrokerHost(), getAMQPPort()).withQueue(queueName).build(); // Publish to queue and rollback XAConnectionFactory connectionFactory = (XAConnectionFactory) adminInitialContext.lookup(JMSClientHelper.QUEUE_XA_CONNECTION_FACTORY); XAConnection xaConnection = connectionFactory.createXAConnection(); xaConnection.start(); XASession xaSession = xaConnection.createXASession(); XAResource xaResource = xaSession.getXAResource(); Session session = xaSession.getSession(); Destination testQueue = (Destination) adminInitialContext.lookup(queueName); MessageProducer producer = session.createProducer(testQueue); Xid xid = JMSClientHelper.getNewXid(); xaResource.start(xid, XAResource.TMNOFLAGS); producer.send(session.createTextMessage("Test 1")); xaResource.end(xid, XAResource.TMSUCCESS); // Test should fail at prepare stage due to no route issue int prepareResponseCode = xaResource.prepare(xid); Assert.assertNotEquals(prepareResponseCode, XAResource.XA_OK, "Prepare should fail due to no route issue"); xaResource.commit(xid, false); session.close(); xaConnection.close(); }
Example #17
Source File: TopicUserAuthorizationTestCase.java From product-ei with Apache License 2.0 | 4 votes |
/** * Runs a test case where a consumer and publisher is created and published with a given user * key from the automation.xml. * * @param userKey The user key mentioned in the automation.xml for a specific user. * @param destinationName The destination name of the topic. * @throws XPathExpressionException * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientConfigurationException * @throws IOException * @throws javax.jms.JMSException * @throws org.wso2.mb.integration.common.clients.exceptions.AndesClientException * @throws javax.naming.NamingException */ private void createPublishAndSubscribeFromUser(String userKey, String destinationName) throws XPathExpressionException, AndesClientConfigurationException, IOException, JMSException, AndesClientException, NamingException { long sendCount = 10L; long expectedCount = 10L; AutomationContext userAutomationContext = new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, userKey); User contextUser = userAutomationContext.getContextTenant().getContextUser(); // Creating a consumer client configuration AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration( getAMQPPort(), contextUser.getUserNameWithoutDomain(), contextUser.getPassword(), ExchangeType.TOPIC, destinationName); consumerConfig.setMaximumMessagesToReceived(expectedCount); consumerConfig.setAsync(false); // Creating a publisher client configuration AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration( getAMQPPort(), contextUser.getUserNameWithoutDomain(), contextUser.getPassword(), ExchangeType.TOPIC, destinationName); publisherConfig.setNumberOfMessagesToSend(sendCount); // Creating clients AndesClient consumerClient = new AndesClient(consumerConfig, true); consumerClient.startClient(); AndesClient publisherClient = new AndesClient(publisherConfig, true); publisherClient.startClient(); AndesClientUtils .waitForMessagesAndShutdown(consumerClient, AndesClientConstants.DEFAULT_RUN_TIME); // Evaluating Assert.assertEquals(publisherClient.getSentMessageCount(), sendCount, "Message sending " + "failed for user : " + contextUser.getUserNameWithoutDomain()); Assert.assertEquals(consumerClient.getReceivedMessageCount(), expectedCount, "Message " + "receiving failed for user : " + contextUser.getUserNameWithoutDomain()); }
Example #18
Source File: QueuePermissionTestCase.java From product-ei with Apache License 2.0 | 4 votes |
/** * Creates a queue by giving queue creation rights to the user. * 1. User is in a role with no permissions. * 2. Admin gives permissions to the role to create queues and for logging in. * 3. User creates a queue. * 4. Validates whether queue is created. * * @throws IOException * @throws UserAdminUserAdminException * @throws XPathExpressionException */ @Test(groups = {"wso2.mb", "queue"}) public void createQueuePermissionTestCase() throws IOException, UserAdminUserAdminException, XPathExpressionException { String queueName = "queueCreationPermission"; AutomationContext authAutomationContext = new AutomationContext("MB", "mb001", FrameworkConstants.SUPER_TENANT_KEY, "queueAuthUser"); User contextUser = authAutomationContext.getContextTenant().getContextUser(); String[] createPermissionUsers = new String[]{contextUser.getUserNameWithoutDomain()}; // Logging into user management as admin UserManagementClient userManagementClient = new UserManagementClient(backendURL, "admin", "admin"); // Removing admin permission for user userManagementClient .updateUserListOfRole(FrameworkConstants.ADMIN_ROLE, null, createPermissionUsers); // Adding roles along with user userManagementClient.addRole(CREATE_QUEUE_PERMISSION_ROLE, createPermissionUsers, new String[]{ADD_QUEUE_PERMISSION, LOGIN_PERMISSION}); driver.get(getLoginURL()); LoginPage loginPage = new LoginPage(driver); // Logging in to the the management console HomePage homePage = loginPage.loginAs(contextUser.getUserNameWithoutDomain(), contextUser.getPassword()); QueueAddPage queueAddPage = homePage.getQueueAddPage(); // Creating a queue by the user and check whether valid dialog pop up is shown Assert.assertEquals(queueAddPage.addQueue(queueName), true); QueuesBrowsePage queuesBrowsePage = homePage.getQueuesBrowsePage(); // Checks whether queue is created in the browsing page Assert.assertEquals(queuesBrowsePage.isQueuePresent(queueName), true); }
Example #19
Source File: NonAdminUserCreationTestCase.java From product-ei with Apache License 2.0 | 4 votes |
protected static User getUser(){ Assert.assertNotNull( "User is not created. Please create the user first", nonAdminUser); return nonAdminUser; }
Example #20
Source File: NonAdminUserCreationTestCase.java From micro-integrator with Apache License 2.0 | 4 votes |
protected static User getUser() { Assert.assertNotNull(nonAdminUser, "User is not created. Please create the user first"); return nonAdminUser; }
Example #21
Source File: SecureServiceClient.java From product-ei with Apache License 2.0 | 3 votes |
public OMElement sendSecuredStockQuoteRequest(User userInfo, String trpUrl, int securityPolicyId, String symbol) throws Exception { return sendSecuredRequest(userInfo, trpUrl, securityPolicyId, createSimpleStockQuoteRequest(symbol), "getQuote"); }
Example #22
Source File: SecureServiceClient.java From micro-integrator with Apache License 2.0 | 3 votes |
public OMElement sendSecuredStockQuoteRequest(User userInfo, String trpUrl, int securityPolicyId, String symbol) throws Exception { return sendSecuredRequest(userInfo, trpUrl, securityPolicyId, createSimpleStockQuoteRequest(symbol), "getQuote"); }
Example #23
Source File: MBIntegrationBaseTest.java From product-ei with Apache License 2.0 | 2 votes |
/** * Return super admin {@link User} object * * @return super admin user * @throws XPathExpressionException if error occurred while reading values */ protected User getSuperTenantAdminUser() throws XPathExpressionException { return automationContext.getSuperTenant().getTenantAdmin(); }