UserNamespaceAuthorizationRestController extends HerdBaseController { @RequestMapping(value = USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX + "/userIds/{userId}/namespaces/{namespace}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_USER_NAMESPACE_AUTHORIZATIONS_PUT) public UserNamespaceAuthorization updateUserNamespaceAuthorization(@PathVariable("userId") String userId, @PathVariable("namespace") String namespace, @RequestBody UserNamespaceAuthorizationUpdateRequest request) { return userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(userId, namespace), request); }  @RequestMapping(value = USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX, method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_USER_NAMESPACE_AUTHORIZATIONS_POST) UserNamespaceAuthorization createUserNamespaceAuthorization(@RequestBody UserNamespaceAuthorizationCreateRequest request); @RequestMapping(value = USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX + "/userIds/{userId}/namespaces/{namespace}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_USER_NAMESPACE_AUTHORIZATIONS_PUT) UserNamespaceAuthorization updateUserNamespaceAuthorization(@PathVariable("userId") String userId, @PathVariable("namespace") String namespace,
        @RequestBody UserNamespaceAuthorizationUpdateRequest request); @RequestMapping(value = USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX + "/userIds/{userId}/namespaces/{namespace}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_USER_NAMESPACE_AUTHORIZATIONS_GET) UserNamespaceAuthorization getUserNamespaceAuthorization(@PathVariable("userId") String userId, @PathVariable("namespace") String namespace); @RequestMapping(value = USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX + "/userIds/{userId}/namespaces/{namespace}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_USER_NAMESPACE_AUTHORIZATIONS_DELETE) UserNamespaceAuthorization deleteUserNamespaceAuthorization(@PathVariable("userId") String userId, @PathVariable("namespace") String namespace); @RequestMapping(value = USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX + "/userIds/{userId}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_USER_NAMESPACE_AUTHORIZATIONS_BY_USERID_GET) UserNamespaceAuthorizations getUserNamespaceAuthorizationsByUserId(@PathVariable("userId") String userId); @RequestMapping(value = USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX + "/namespaces/{namespace}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_USER_NAMESPACE_AUTHORIZATIONS_BY_NAMESPACE_GET) UserNamespaceAuthorizations getUserNamespaceAuthorizationsByNamespace(@PathVariable("namespace") String namespace); static final String USER_NAMESPACE_AUTHORIZATIONS_URI_PREFIX; }
@Test public void testUpdateUserNamespaceAuthorization() { UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE); UserNamespaceAuthorization userNamespaceAuthorization = new UserNamespaceAuthorization(ID, key, Arrays.asList(NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT)); UserNamespaceAuthorizationUpdateRequest request = new UserNamespaceAuthorizationUpdateRequest(Arrays.asList(NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT)); when(userNamespaceAuthorizationService.updateUserNamespaceAuthorization(key, request)).thenReturn(userNamespaceAuthorization); UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationRestController.updateUserNamespaceAuthorization(key.getUserId(), key.getNamespace(), request); verify(userNamespaceAuthorizationService).updateUserNamespaceAuthorization(key, request); verifyNoMoreInteractions(userNamespaceAuthorizationService); assertEquals(userNamespaceAuthorization, resultUserNamespaceAuthorization); }