This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch custos-integration
in repository https://gitbox.apache.org/repos/asf/airavata-data-catalog.git

commit 6399bedf21e357901b1cf3096f7226ab001d39dc
Author: Marcus Christie <[email protected]>
AuthorDate: Wed May 3 10:00:14 2023 -0400

    Utility class to generate test Custos user for local testing and development
---
 .../api/sharing/CustosTestDataBootstrap.java       | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git 
a/data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/CustosTestDataBootstrap.java
 
b/data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/CustosTestDataBootstrap.java
new file mode 100644
index 0000000..02b26dc
--- /dev/null
+++ 
b/data-catalog-api/server/custos-sharing/src/main/java/org/apache/airavata/datacatalog/api/sharing/CustosTestDataBootstrap.java
@@ -0,0 +1,36 @@
+package org.apache.airavata.datacatalog.api.sharing;
+
+import java.io.IOException;
+
+import org.apache.custos.clients.CustosClientProvider;
+import org.apache.custos.iam.service.FindUsersResponse;
+import org.apache.custos.user.management.client.UserManagementClient;
+
+public class CustosTestDataBootstrap {
+    public static void main(String[] args) throws IOException {
+
+        // Super tenant
+        // String clientId = System.getenv("CUSTOS_SUPER_CLIENT_ID");
+        // String clientSec = System.getenv("CUSTOS_SUPER_CLIENT_SEC");
+        String childClientId = System.getenv("CUSTOS_CLIENT_ID");
+        String clientId = System.getenv("CUSTOS_CLIENT_ID");
+        String clientSec = System.getenv("CUSTOS_CLIENT_SEC");
+        CustosClientProvider custosClientProvider = new 
CustosClientProvider.Builder().setServerHost("localhost")
+                .setServerPort(7000)
+                .setClientId(clientId) // client Id generated from above step 
or any active tenant id
+                .setClientSec(clientSec)
+                .usePlainText(true) // Don't use this in production setup
+                .build();
+        UserManagementClient userManagementClient = 
custosClientProvider.getUserManagementClient();
+        String testUsername = "demouser";
+        // userManagementClient.registerUser(testUsername, "Demo", "User",
+        // "testpassword", "[email protected]", false);
+        // userManagementClient.enableUser(testUsername);
+        // FindUsersResponse findUsersResponse =
+        // userManagementClient.findUser(testUsername, null, null, null, 0, 1);
+        FindUsersResponse findUsersResponse = 
userManagementClient.findUser(childClientId, testUsername, null, null,
+                null, 0, 1);
+        System.out.println("findUsersResponse=" + findUsersResponse);
+    }
+
+}

Reply via email to