### Question:
AuthorizedAddress { public static AuthorizedAddress authorizeAddress(OperationContext context, ModelNode operation) { ModelNode address = operation.get(ModelDescriptionConstants.OP_ADDR); ModelNode testOp = new ModelNode(); testOp.get(OP).set(READ_RESOURCE_OPERATION); testOp.get(OP_ADDR).set(address); AuthorizationResult authResult = context.authorize(testOp, ADDRESS_EFFECT); if (authResult.getDecision() == AuthorizationResult.Decision.PERMIT) { return new AuthorizedAddress(address, false); } ModelNode partialAddress = new ModelNode().setEmptyList(); ModelNode elidedAddress = new ModelNode().setEmptyList(); for (Property prop : address.asPropertyList()) { partialAddress.add(prop); testOp.get(OP_ADDR).set(partialAddress); authResult = context.authorize(testOp, ADDRESS_EFFECT); if (authResult.getDecision() == AuthorizationResult.Decision.DENY) { elidedAddress.add(prop.getName(), HIDDEN); return new AuthorizedAddress(elidedAddress, true); } else { elidedAddress.add(prop); } } ModelNode strange = new ModelNode(); strange.add(HIDDEN, HIDDEN); return new AuthorizedAddress(strange, true); } AuthorizedAddress(ModelNode address, boolean elided); @Override int hashCode(); @Override String toString(); @Override boolean equals(Object obj); ModelNode getAddress(); boolean isElided(); static AuthorizedAddress authorizeAddress(OperationContext context, ModelNode operation);  }### Answer:
@Test public void testAccessAuthorizedAddress() { ModelNode address = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,"test.war"), PathElement.pathElement(SUBSYSTEM, "Undertow")).toModelNode(); ModelNode authorizedAddress = address; OperationContext context = new AuthorizationOperationContext(authorizedAddress.asString()); ModelNode operation = new ModelNode(); operation.get(OP).set(READ_RESOURCE_OPERATION); operation.get(OP_ADDR).set(address); AuthorizedAddress expResult = new AuthorizedAddress(authorizedAddress, false); AuthorizedAddress result = AuthorizedAddress.authorizeAddress(context, operation); assertEquals(expResult, result); }
@Test public void testAccessUnauthorizedAddress() { ModelNode address = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,"test.war"), PathElement.pathElement(SUBSYSTEM, "Undertow")).toModelNode(); ModelNode authorizedAddress = PathAddress.EMPTY_ADDRESS.toModelNode(); OperationContext context = new AuthorizationOperationContext(authorizedAddress.asString()); ModelNode operation = new ModelNode(); operation.get(OP).set(READ_RESOURCE_OPERATION); operation.get(OP_ADDR).set(address); AuthorizedAddress expResult = new AuthorizedAddress(PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,"<hidden>")).toModelNode(), true); AuthorizedAddress result = AuthorizedAddress.authorizeAddress(context, operation); assertEquals(expResult, result); }
@Test public void testAccessParialUnauthorizedAddress() { ModelNode address = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,"test.war"), PathElement.pathElement(SUBSYSTEM, "Undertow")).toModelNode(); ModelNode authorizedAddress = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,"test.war")).toModelNode(); OperationContext context = new AuthorizationOperationContext(authorizedAddress.asString()); ModelNode operation = new ModelNode(); operation.get(OP).set(READ_RESOURCE_OPERATION); operation.get(OP_ADDR).set(address); AuthorizedAddress expResult = new AuthorizedAddress(PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,"test.war"), PathElement.pathElement(SUBSYSTEM,"<hidden>")).toModelNode(), true); AuthorizedAddress result = AuthorizedAddress.authorizeAddress(context, operation); assertEquals(expResult, result); }