@Test(dependsOnMethods = {"testRegisterPermissionWithInvalidResource"}) public void cleanUp() { if (resource != null) { TUma.deleteResource(url, pat, umaRegisterResourcePath, resource.getId()); } } }
/** * Test for getting UMA resource descriptions */ @Test(dependsOnMethods = {"testModifyResource"}) public void testGetResources() throws Exception { final List<String> list = TUma.getResourceList(url, pat, umaRegisterResourcePath); assertTrue(list != null && !list.isEmpty() && list.contains(resourceStatus.getId()), "Resource list is empty"); }
/** * Test for deleting UMA resource descriptions */ @Test(dependsOnMethods = {"testGetResources"}) public void testDeleteResource() throws Exception { TUma.deleteResource(url, pat, umaRegisterResourcePath, resourceStatus.getId()); } }
@Test(dependsOnMethods = { "_7_requesterAccessProtectedResourceWithEnoughPermissionsRpt" }) @Parameters({ "umaRegisterResourcePath" }) public void cleanUp(String umaRegisterResourcePath) { if (resource != null) { TUma.deleteResource(url, pat, umaRegisterResourcePath, resource.getId()); } }
@Test(dependsOnMethods = { "init" }) public void testRegisterPermission() throws Exception { final UmaPermission r = new UmaPermission(); r.setResourceId(resource.getId()); r.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view")); final PermissionTicket ticket = TUma.registerPermission(url, pat, r, umaPermissionPath); UmaTestUtil.assert_(ticket); }
@Test(dependsOnMethods = {"testRegisterResource"}) public void testModifyResource() throws Exception { final UmaResource resource = new UmaResource(); resource.setName("Server Photo Album 2"); resource.setIconUri("http://www.example.com/icons/flower.png"); resource.setScopes( Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all")); final UmaResourceResponse status = TUma.modifyResource(url, pat, umaRegisterResourcePath, resourceStatus.getId(), resource); UmaTestUtil.assert_(status); }
try { final UmaPermission r = new UmaPermission(); r.setResourceId(resource.getId() + "x");
@Test(dependsOnMethods = { "_3_hostDeterminesRptStatus" }) @Parameters({"umaPermissionPath"}) public void _4_registerPermissionForRpt(String umaPermissionPath) throws Exception { final UmaPermission r = new UmaPermission(); r.setResourceId(resource.getId()); r.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view")); ticket = TUma.registerPermission(url, pat, r, umaPermissionPath); UmaTestUtil.assert_(ticket); }
public String registerResourceWithScopeExpression(String scopeExpression) throws Exception { try { UmaResource resource = new UmaResource(); resource.setName("Photo Album"); resource.setIconUri("http://www.example.com/icons/flower.png"); resource.setScopeExpression(scopeExpression); resource.setType("myType"); UmaResourceResponse resourceStatus = getResourceService().addResource("Bearer " + pat.getAccessToken(), resource); UmaTestUtil.assert_(resourceStatus); this.resourceIdWithScopeExpression = resourceStatus.getId(); return this.resourceIdWithScopeExpression; } catch (ClientResponseFailure ex) { System.err.println(ex.getResponse().getEntity(String.class)); throw ex; } }
public String registerResource(List<String> scopes) throws Exception { try { UmaResource resource = new UmaResource(); resource.setName("Photo Album"); resource.setIconUri("http://www.example.com/icons/flower.png"); resource.setScopes(scopes); resource.setType("myType"); UmaResourceResponse resourceStatus = getResourceService().addResource("Bearer " + pat.getAccessToken(), resource); UmaTestUtil.assert_(resourceStatus); this.resourceId = resourceStatus.getId(); return this.resourceId; } catch (ClientResponseFailure ex) { System.err.println(ex.getResponse().getEntity(String.class)); throw ex; } }