kumaab commented on code in PR #928:
URL: https://github.com/apache/ranger/pull/928#discussion_r3165153567


##########
ranger-examples/sample-client/src/main/java/org/apache/ranger/examples/pdpclient/RemoteAuthzClient.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ranger.examples.pdpclient;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.ranger.authz.api.RangerAuthorizer;
+import org.apache.ranger.authz.api.RangerAuthorizerFactory;
+import org.apache.ranger.authz.model.RangerAccessContext;
+import org.apache.ranger.authz.model.RangerAccessInfo;
+import org.apache.ranger.authz.model.RangerAuthzRequest;
+import org.apache.ranger.authz.model.RangerAuthzResult;
+import org.apache.ranger.authz.model.RangerResourceInfo;
+import org.apache.ranger.authz.model.RangerUserInfo;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Properties;
+import java.util.Set;
+
+public final class RemoteAuthzClient {
+    private static final String DEFAULT_PROPERTIES_RESOURCE = 
"/tmp/ranger-authz-remote-test.properties";
+
+    private static final String PROP_TEST_REQUEST_ID            = 
"ranger.authz.remote.test.requestId";
+    private static final String PROP_TEST_EXPECT_DECISION       = 
"ranger.authz.remote.test.expect.decision";
+    private static final String PROP_TEST_USER_NAME             = 
"ranger.authz.remote.test.user.name";
+    private static final String PROP_TEST_USER_GROUPS           = 
"ranger.authz.remote.test.user.groups";
+    private static final String PROP_TEST_USER_ROLES            = 
"ranger.authz.remote.test.user.roles";
+    private static final String PROP_TEST_ACCESS_ACTION         = 
"ranger.authz.remote.test.access.action";
+    private static final String PROP_TEST_ACCESS_PERMISSIONS    = 
"ranger.authz.remote.test.access.permissions";
+    private static final String PROP_TEST_RESOURCE_NAME         = 
"ranger.authz.remote.test.resource.name";
+    private static final String PROP_TEST_RESOURCE_SUBRESOURCES = 
"ranger.authz.remote.test.resource.subResources";
+    private static final String PROP_TEST_CONTEXT_SERVICE_TYPE  = 
"ranger.authz.remote.test.context.serviceType";
+    private static final String PROP_TEST_CONTEXT_SERVICE_NAME  = 
"ranger.authz.remote.test.context.serviceName";
+    private static final String PROP_TEST_CONTEXT_CLIENT_IP     = 
"ranger.authz.remote.test.context.clientIpAddress";
+
+    private RemoteAuthzClient() {
+    }
+
+    public static void main(String[] args) throws Exception {
+        String     propertiesLocation = args != null && args.length > 0 ? 
args[0] : "classpath:" + DEFAULT_PROPERTIES_RESOURCE;
+        Properties properties         = loadProperties(propertiesLocation);
+
+        System.out.println("Loaded properties from: " + propertiesLocation);
+
+        RangerAuthzResult result = run(properties);

Review Comment:
   Reading a request from JSON file makes more sense, it allows requests for 
other services to be tested as well. updated the PR, thanks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to