{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/product-apim/pulls/comments/57605058","id":57605058,"diff_hunk":"@@ -0,0 +1,162 @@\n+/*\n+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.wso2.am.integration.tests.other;\n+\n+import org.apache.commons.httpclient.HttpStatus;\n+import org.testng.annotations.AfterMethod;\n+import org.testng.annotations.BeforeMethod;\n+import org.testng.annotations.Test;\n+import org.wso2.am.integration.test.utils.APIManagerIntegrationTestException;\n+import org.wso2.am.integration.test.utils.base.APIMIntegrationBaseTest;\n+import org.wso2.am.integration.test.utils.bean.APILifeCycleState;\n+import org.wso2.am.integration.test.utils.bean.APILifeCycleStateRequest;\n+import org.wso2.am.integration.test.utils.bean.APIRequest;\n+import org.wso2.am.integration.test.utils.bean.SubscriptionRequest;\n+import org.wso2.am.integration.test.utils.clients.APIPublisherRestClient;\n+import org.wso2.am.integration.test.utils.clients.APIStoreRestClient;\n+import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;\n+import org.wso2.carbon.integration.common.admin.client.UserManagementClient;\n+import org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException;\n+\n+import javax.xml.xpath.XPathExpressionException;\n+import java.net.URL;\n+import java.rmi.RemoteException;\n+\n+import static org.testng.Assert.assertTrue;\n+\n+/**\n+ * None of the apis are visible in API Store when permissions for one API has changed.\n+ * This is test class tests the fix for this issue\n+ *\n+ * @see <a href=\"https://wso2.org/jira/browse/APIMANAGER-4373\">APIMANAGER-4373</a>\n+ */\n+public class APIMANAGER4373BrokenAPIInStoreTestCase extends APIMIntegrationBaseTest {\n+    private final String USER_PASSWORD = \"123123\";\n+    private final String PERMISSION_LOGIN = \"/permission/admin/login\";\n+    private final String PERMISSION_API_SUBSCRIBE = \"/permission/admin/manage/api/subscribe\";\n+    private final String FIRST_USER = \"APIMANAGER4373_user\";\n+    private final String FIRST_ROLE = \"APIMANAGER4373_role1\";\n+    private final String SECOND_ROLE = \"APIMANAGER4373_role2\";\n+    private final String APP_NAME = \"APIMANAGER4373\";\n+    private final String BROKEN_API = \"brokenAPI\";\n+    private final String HEALTHY_API = \"healthyAPI\";\n+    private final String EP_URL = \"http://gdata.youtube.com/feeds/api/standardfeeds\";\n+    private final String API_VERSION = \"1.0.0\";\n+    private String contextUsername = \"admin\";\n+    private String contextUserPassword = \"admin\";\n+    private UserManagementClient userManagementClient;\n+    private APIPublisherRestClient apiPublisher;\n+    private APIStoreRestClient apiStoreRestClient;\n+    private String publisherURLHttp;\n+    private String storeURLHttp;\n+\n+    @BeforeMethod\n+    public void init() {\n+        try {\n+            super.init();\n+            publisherURLHttp = publisherUrls.getWebAppURLHttp();\n+            storeURLHttp = storeUrls.getWebAppURLHttp();\n+            apiPublisher = new APIPublisherRestClient(publisherURLHttp);\n+            apiStoreRestClient = new APIStoreRestClient(storeURLHttp);\n+            contextUsername = publisherContext.getContextTenant().getContextUser().getUserName();\n+            contextUserPassword = publisherContext.getContextTenant().getContextUser().getPassword();\n+            userManagementClient = new UserManagementClient(publisherContext.getContextUrls().getBackEndUrl(),\n+                    contextUsername, contextUserPassword);\n+\n+            userManagementClient\n+                    .addRole(FIRST_ROLE, new String[] {}, new String[] { PERMISSION_LOGIN, PERMISSION_API_SUBSCRIBE });\n+            userManagementClient\n+                    .addRole(SECOND_ROLE, new String[] {}, new String[] { PERMISSION_LOGIN, PERMISSION_API_SUBSCRIBE });\n+            userManagementClient.addUser(FIRST_USER, USER_PASSWORD, new String[] { FIRST_ROLE }, FIRST_USER);\n+        } catch (APIManagerIntegrationTestException e) {\n+            assertTrue(false, \"Error occurred while initializing testcase.\");\n+        } catch (RemoteException e) {\n+            assertTrue(false, \"Error occurred while adding new users.\");\n+        } catch (UserAdminUserAdminException e) {\n+            assertTrue(false, \"Error occurred while adding new users.\");\n+        } catch (XPathExpressionException e) {\n+            assertTrue(false, \"Error occurred while retrieving context.\");\n+        }\n+    }\n+\n+    @Test(groups = \"wso2.am\", description = \"Test effect of changing the role of subscribed API\")\n+    public void testAPIRoleChangeEffectInStore() throws Exception {\n+        // create two apis\n+        apiPublisher.login(contextUsername, contextUserPassword);\n+        APIRequest brokenApiRequest = new APIRequest(BROKEN_API, BROKEN_API, new URL(EP_URL));\n+        brokenApiRequest.setVersion(API_VERSION);\n+        brokenApiRequest.setProvider(contextUsername);\n+        brokenApiRequest.setVisibility(\"restricted\");\n+        brokenApiRequest.setRoles(FIRST_ROLE);\n+        apiPublisher.addAPI(brokenApiRequest);\n+        APILifeCycleStateRequest updateRequest = new APILifeCycleStateRequest(BROKEN_API, contextUsername,\n+                APILifeCycleState.PUBLISHED);\n+        apiPublisher.changeAPILifeCycleStatus(updateRequest);\n+\n+        APIRequest healthyApiRequest = new APIRequest(HEALTHY_API, HEALTHY_API, new URL(EP_URL));\n+        healthyApiRequest.setVersion(API_VERSION);\n+        healthyApiRequest.setProvider(contextUsername);\n+        healthyApiRequest.setVisibility(\"restricted\");\n+        healthyApiRequest.setRoles(FIRST_ROLE);\n+        apiPublisher.addAPI(healthyApiRequest);\n+        updateRequest = new APILifeCycleStateRequest(HEALTHY_API, contextUsername, APILifeCycleState.PUBLISHED);\n+        apiPublisher.changeAPILifeCycleStatus(updateRequest);\n+\n+        // subscribe both apis\n+        apiStoreRestClient.login(FIRST_USER, USER_PASSWORD);\n+\n+        apiStoreRestClient.addApplication(APP_NAME, \"Unlimited\", \"\", \"\");\n+        SubscriptionRequest subscriptionRequest = new SubscriptionRequest(BROKEN_API, contextUsername);\n+        subscriptionRequest.setApplicationName(APP_NAME);\n+        apiStoreRestClient.subscribe(subscriptionRequest);\n+        subscriptionRequest = new SubscriptionRequest(HEALTHY_API, contextUsername);\n+        subscriptionRequest.setApplicationName(APP_NAME);\n+        apiStoreRestClient.subscribe(subscriptionRequest);\n+\n+        brokenApiRequest.setRoles(SECOND_ROLE);\n+        brokenApiRequest.setTags(\"updated\");\n+        Thread.sleep(1000);\n+        apiPublisher.updateAPI(brokenApiRequest);\n+\n+        HttpResponse response = new HttpResponse(\"\", HttpStatus.SC_INTERNAL_SERVER_ERROR);\n+        try {\n+            response = apiStoreRestClient.getAllSubscriptions();\n+        } catch (Exception e) {\n+            // Expectation of this test case is to test whether permitted apis are returned to the store.","path":"modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/other/APIMANAGER4373BrokenAPIInStoreTestCase.java","position":139,"original_position":139,"commit_id":"96594fc022a5419cd2e1fb8872f3c996fb0cf445","original_commit_id":"96594fc022a5419cd2e1fb8872f3c996fb0cf445","user":{"login":"nuwanw","id":7113382,"avatar_url":"https://avatars.githubusercontent.com/u/7113382?v=3","gravatar_id":"","url":"https://api.github.com/users/nuwanw","html_url":"https://github.com/nuwanw","followers_url":"https://api.github.com/users/nuwanw/followers","following_url":"https://api.github.com/users/nuwanw/following{/other_user}","gists_url":"https://api.github.com/users/nuwanw/gists{/gist_id}","starred_url":"https://api.github.com/users/nuwanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuwanw/subscriptions","organizations_url":"https://api.github.com/users/nuwanw/orgs","repos_url":"https://api.github.com/users/nuwanw/repos","events_url":"https://api.github.com/users/nuwanw/events{/privacy}","received_events_url":"https://api.github.com/users/nuwanw/received_events","type":"User","site_admin":false},"body":"Better to have an assert to verify the expected exception message","created_at":"2016-03-28T17:55:28Z","updated_at":"2016-03-28T17:55:28Z","html_url":"https://github.com/wso2/product-apim/pull/617#discussion_r57605058","pull_request_url":"https://api.github.com/repos/wso2/product-apim/pulls/617","_links":{"self":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/comments/57605058"},"html":{"href":"https://github.com/wso2/product-apim/pull/617#discussion_r57605058"},"pull_request":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/617"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/product-apim/pulls/617","id":56317479,"html_url":"https://github.com/wso2/product-apim/pull/617","diff_url":"https://github.com/wso2/product-apim/pull/617.diff","patch_url":"https://github.com/wso2/product-apim/pull/617.patch","issue_url":"https://api.github.com/repos/wso2/product-apim/issues/617","number":617,"state":"closed","locked":false,"title":"Add integration test for APIMANAGER-4373","user":{"login":"praminda","id":2655553,"avatar_url":"https://avatars.githubusercontent.com/u/2655553?v=3","gravatar_id":"","url":"https://api.github.com/users/praminda","html_url":"https://github.com/praminda","followers_url":"https://api.github.com/users/praminda/followers","following_url":"https://api.github.com/users/praminda/following{/other_user}","gists_url":"https://api.github.com/users/praminda/gists{/gist_id}","starred_url":"https://api.github.com/users/praminda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praminda/subscriptions","organizations_url":"https://api.github.com/users/praminda/orgs","repos_url":"https://api.github.com/users/praminda/repos","events_url":"https://api.github.com/users/praminda/events{/privacy}","received_events_url":"https://api.github.com/users/praminda/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-18T09:20:58Z","updated_at":"2016-03-28T17:55:28Z","closed_at":"2016-02-15T09:31:41Z","merged_at":"2016-02-15T09:31:41Z","merge_commit_sha":"0a517751072dd7f41ad1c04b3b41c9a1d968e504","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/product-apim/pulls/617/commits","review_comments_url":"https://api.github.com/repos/wso2/product-apim/pulls/617/comments","review_comment_url":"https://api.github.com/repos/wso2/product-apim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/product-apim/issues/617/comments","statuses_url":"https://api.github.com/repos/wso2/product-apim/statuses/96594fc022a5419cd2e1fb8872f3c996fb0cf445","head":{"label":"praminda:APIMANAGER-4373_Intergration","ref":"APIMANAGER-4373_Intergration","sha":"96594fc022a5419cd2e1fb8872f3c996fb0cf445","user":{"login":"praminda","id":2655553,"avatar_url":"https://avatars.githubusercontent.com/u/2655553?v=3","gravatar_id":"","url":"https://api.github.com/users/praminda","html_url":"https://github.com/praminda","followers_url":"https://api.github.com/users/praminda/followers","following_url":"https://api.github.com/users/praminda/following{/other_user}","gists_url":"https://api.github.com/users/praminda/gists{/gist_id}","starred_url":"https://api.github.com/users/praminda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praminda/subscriptions","organizations_url":"https://api.github.com/users/praminda/orgs","repos_url":"https://api.github.com/users/praminda/repos","events_url":"https://api.github.com/users/praminda/events{/privacy}","received_events_url":"https://api.github.com/users/praminda/received_events","type":"User","site_admin":false},"repo":{"id":41715940,"name":"product-apim","full_name":"praminda/product-apim","owner":{"login":"praminda","id":2655553,"avatar_url":"https://avatars.githubusercontent.com/u/2655553?v=3","gravatar_id":"","url":"https://api.github.com/users/praminda","html_url":"https://github.com/praminda","followers_url":"https://api.github.com/users/praminda/followers","following_url":"https://api.github.com/users/praminda/following{/other_user}","gists_url":"https://api.github.com/users/praminda/gists{/gist_id}","starred_url":"https://api.github.com/users/praminda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praminda/subscriptions","organizations_url":"https://api.github.com/users/praminda/orgs","repos_url":"https://api.github.com/users/praminda/repos","events_url":"https://api.github.com/users/praminda/events{/privacy}","received_events_url":"https://api.github.com/users/praminda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/praminda/product-apim","description":"","fork":true,"url":"https://api.github.com/repos/praminda/product-apim","forks_url":"https://api.github.com/repos/praminda/product-apim/forks","keys_url":"https://api.github.com/repos/praminda/product-apim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praminda/product-apim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praminda/product-apim/teams","hooks_url":"https://api.github.com/repos/praminda/product-apim/hooks","issue_events_url":"https://api.github.com/repos/praminda/product-apim/issues/events{/number}","events_url":"https://api.github.com/repos/praminda/product-apim/events","assignees_url":"https://api.github.com/repos/praminda/product-apim/assignees{/user}","branches_url":"https://api.github.com/repos/praminda/product-apim/branches{/branch}","tags_url":"https://api.github.com/repos/praminda/product-apim/tags","blobs_url":"https://api.github.com/repos/praminda/product-apim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praminda/product-apim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praminda/product-apim/git/refs{/sha}","trees_url":"https://api.github.com/repos/praminda/product-apim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praminda/product-apim/statuses/{sha}","languages_url":"https://api.github.com/repos/praminda/product-apim/languages","stargazers_url":"https://api.github.com/repos/praminda/product-apim/stargazers","contributors_url":"https://api.github.com/repos/praminda/product-apim/contributors","subscribers_url":"https://api.github.com/repos/praminda/product-apim/subscribers","subscription_url":"https://api.github.com/repos/praminda/product-apim/subscription","commits_url":"https://api.github.com/repos/praminda/product-apim/commits{/sha}","git_commits_url":"https://api.github.com/repos/praminda/product-apim/git/commits{/sha}","comments_url":"https://api.github.com/repos/praminda/product-apim/comments{/number}","issue_comment_url":"https://api.github.com/repos/praminda/product-apim/issues/comments{/number}","contents_url":"https://api.github.com/repos/praminda/product-apim/contents/{+path}","compare_url":"https://api.github.com/repos/praminda/product-apim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praminda/product-apim/merges","archive_url":"https://api.github.com/repos/praminda/product-apim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praminda/product-apim/downloads","issues_url":"https://api.github.com/repos/praminda/product-apim/issues{/number}","pulls_url":"https://api.github.com/repos/praminda/product-apim/pulls{/number}","milestones_url":"https://api.github.com/repos/praminda/product-apim/milestones{/number}","notifications_url":"https://api.github.com/repos/praminda/product-apim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praminda/product-apim/labels{/name}","releases_url":"https://api.github.com/repos/praminda/product-apim/releases{/id}","deployments_url":"https://api.github.com/repos/praminda/product-apim/deployments","created_at":"2015-09-01T03:58:52Z","updated_at":"2016-01-11T11:12:55Z","pushed_at":"2016-03-10T04:27:46Z","git_url":"git://github.com/praminda/product-apim.git","ssh_url":"git@github.com:praminda/product-apim.git","clone_url":"https://github.com/praminda/product-apim.git","svn_url":"https://github.com/praminda/product-apim","homepage":null,"size":80109,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2:master","ref":"master","sha":"1a7ff59413e60c1d643a9e119d52a14282317120","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":20717348,"name":"product-apim","full_name":"wso2/product-apim","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/product-apim","description":"","fork":false,"url":"https://api.github.com/repos/wso2/product-apim","forks_url":"https://api.github.com/repos/wso2/product-apim/forks","keys_url":"https://api.github.com/repos/wso2/product-apim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/product-apim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/product-apim/teams","hooks_url":"https://api.github.com/repos/wso2/product-apim/hooks","issue_events_url":"https://api.github.com/repos/wso2/product-apim/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/product-apim/events","assignees_url":"https://api.github.com/repos/wso2/product-apim/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/product-apim/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/product-apim/tags","blobs_url":"https://api.github.com/repos/wso2/product-apim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/product-apim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/product-apim/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/product-apim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/product-apim/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/product-apim/languages","stargazers_url":"https://api.github.com/repos/wso2/product-apim/stargazers","contributors_url":"https://api.github.com/repos/wso2/product-apim/contributors","subscribers_url":"https://api.github.com/repos/wso2/product-apim/subscribers","subscription_url":"https://api.github.com/repos/wso2/product-apim/subscription","commits_url":"https://api.github.com/repos/wso2/product-apim/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/product-apim/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/product-apim/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/product-apim/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/product-apim/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/product-apim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/product-apim/merges","archive_url":"https://api.github.com/repos/wso2/product-apim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/product-apim/downloads","issues_url":"https://api.github.com/repos/wso2/product-apim/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/product-apim/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/product-apim/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/product-apim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/product-apim/labels{/name}","releases_url":"https://api.github.com/repos/wso2/product-apim/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/product-apim/deployments","created_at":"2014-06-11T08:05:00Z","updated_at":"2016-03-25T07:10:35Z","pushed_at":"2016-03-28T12:56:44Z","git_url":"git://github.com/wso2/product-apim.git","ssh_url":"git@github.com:wso2/product-apim.git","clone_url":"https://github.com/wso2/product-apim.git","svn_url":"https://github.com/wso2/product-apim","homepage":null,"size":184315,"stargazers_count":19,"watchers_count":19,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":120,"mirror_url":null,"open_issues_count":11,"forks":120,"open_issues":11,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/617"},"html":{"href":"https://github.com/wso2/product-apim/pull/617"},"issue":{"href":"https://api.github.com/repos/wso2/product-apim/issues/617"},"comments":{"href":"https://api.github.com/repos/wso2/product-apim/issues/617/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/617/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/617/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/product-apim/statuses/96594fc022a5419cd2e1fb8872f3c996fb0cf445"}}}}