diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 960370a..a38e127 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,12 +21,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Java for publishing to Maven Central Repository - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: temurin @@ -38,7 +38,7 @@ jobs: run: brew tap aserto-dev/tap && brew install aserto-dev/tap/topaz && topaz install - name: Run all tests - run: mvn clean test -Pintegration + run: mvn --no-transfer-progress clean test -Pintegration release: runs-on: ubuntu-latest needs: build @@ -46,35 +46,37 @@ jobs: name: Release to maven central steps: - name: Read Configuration - uses: hashicorp/vault-action@v2.5.0 + uses: hashicorp/vault-action@v3 id: vault with: url: ${{ env.VAULT_ADDR }} token: ${{ secrets.VAULT_TOKEN }} secrets: | kv/data/MavenCentral "USERNAME" | MAVEN_USERNAME; - kv/data/MavenCentral "PASSWORD" | MAVEN_PASSWORD; + kv/data/MavenCentral "PASSWORD" | MAVEN_CENTRAL_TOKEN; kv/data/MavenCentral "GPG_PASSPHRASE" | MAVEN_GPG_PASSPHRASE; - kv/data/MavenCentral "PRIVATE_GPG_KEY" | GPG_PRIVATE_KEY; + kv/data/MavenCentral "PRIVATE_GPG_KEY" | MAVEN_GPG_PRIVATE_KEY; + kv/data/MavenCentral "TOKEN_USERNAME" | TOKEN_USERNAME; + kv/data/MavenCentral "TOKEN_PASSWORD" | TOKEN_PASSWORD; - name: Set up Java for publishing to Maven Central Repository - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: temurin server-id: ossrh - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} + server-username: TOKEN_USERNAME + server-password: TOKEN_PASSWORD + gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }} gpg-passphrase: MAVEN_GPG_PASSPHRASE - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: build artifact - run: mvn clean package + run: mvn --no-transfer-progress clean package - name: Create release uses: ncipollo/release-action@v1 @@ -84,9 +86,4 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Publish to the Maven Central Repository - run: | - mvn \ - --no-transfer-progress \ - --batch-mode \ - -Pci-cd \ - deploy + run: mvn --no-transfer-progress --batch-mode -Pci-cd deploy diff --git a/LICENSE b/LICENSE index 261eeb9..601d300 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2023 Aserto Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 9650f76..8e2d41e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Java library for Aserto services > **Warning** > -> **0.21.0** is the latest version published to maven central. Versions starting with 1.0.z have been removed from maven central and are no longer available for download. +> **0.31.1** is the latest version published to maven central. Versions starting with 1.0.z have been removed from maven central and are no longer available for download. ### Build `mvn clean install` diff --git a/examples/authz-example/pom.xml b/examples/authz-example/pom.xml index deb93ad..5a6956e 100644 --- a/examples/authz-example/pom.xml +++ b/examples/authz-example/pom.xml @@ -6,7 +6,7 @@ org.example authz-example - 1.0.0 + 1.0.0-SNAPSHOT 19 @@ -18,7 +18,7 @@ com.aserto aserto-java - 0.21.00 + 0.31.1 @@ -27,7 +27,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.1 + 3.6.0 false diff --git a/examples/directory-example/pom.xml b/examples/directory-example/pom.xml index 2201a89..1989944 100644 --- a/examples/directory-example/pom.xml +++ b/examples/directory-example/pom.xml @@ -6,7 +6,7 @@ org.example directory-example - 0.0.1 + 1.0.0-SNAPSHOT 17 @@ -18,7 +18,7 @@ com.aserto aserto-java - 0.21.00 + 0.31.1 @@ -27,7 +27,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.1 + 3.6.0 false diff --git a/pom.xml b/pom.xml index 895d5e4..707f65e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.aserto aserto-java - 0.31.0 + 0.31.1 ${project.groupId}:${project.artifactId} Java SDK to interact with aserto services @@ -41,8 +41,8 @@ 17 UTF-8 - 1.60.1 - 2.22.0 + 1.64.0 + 2.23.1 IntegrationTest @@ -50,25 +50,25 @@ com.aserto java-authorizer - 0.20.8 + 0.20.11 com.aserto java-directory - 0.31.0 + 0.31.2 org.junit.jupiter junit-jupiter-engine - 5.10.1 + 5.10.2 test org.assertj assertj-core - 3.24.2 + 3.26.0 test @@ -115,7 +115,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.4 sign-artifacts @@ -146,7 +146,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -159,7 +159,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.3 + 3.7.0 attach-javadocs @@ -174,7 +174,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 true ossrh diff --git a/src/test/java/AuthzClientIntegrationTest.java b/src/test/java/AuthzClientIntegrationTest.java index 772a063..c51d1cd 100644 --- a/src/test/java/AuthzClientIntegrationTest.java +++ b/src/test/java/AuthzClientIntegrationTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import utils.IntegrationTestsExtenion; +import utils.IntegrationTestsExtension; import javax.net.ssl.SSLException; import java.io.IOException; @@ -16,7 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @Tag("IntegrationTest") -@ExtendWith({IntegrationTestsExtenion.class}) +@ExtendWith({IntegrationTestsExtension.class}) class AuthzClientIntegrationTest { @Test void testBuildAuthzClient() throws IOException { @@ -25,7 +25,7 @@ void testBuildAuthzClient() throws IOException { .withHost("localhost") .withPort(8282) .withInsecure(false) - .withCACertPath(System.getProperty("user.home") + "/.config/topaz/certs/grpc-ca.crt") + .withCACertPath(System.getProperty("user.home") + "/.local/share/topaz/certs/grpc-ca.crt") .build(); AuthzClient authzClient = new AuthzClient(channel); diff --git a/src/test/java/DirectoryClientTest.java b/src/test/java/DirectoryClientTest.java index 30d7c94..a556139 100644 --- a/src/test/java/DirectoryClientTest.java +++ b/src/test/java/DirectoryClientTest.java @@ -18,7 +18,7 @@ import io.grpc.StatusRuntimeException; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; -import utils.IntegrationTestsExtenion; +import utils.IntegrationTestsExtension; import javax.net.ssl.SSLException; @@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.*; @Tag("IntegrationTest") -@ExtendWith({IntegrationTestsExtenion.class}) +@ExtendWith({IntegrationTestsExtension.class}) class DirectoryClientTest { private static DirectoryClient directoryClient; private static ManagedChannel channel; @@ -138,7 +138,7 @@ void testGetUserWithNoRelations() throws UninitilizedClientException { // Assert assertThat(getObjectResponse.getResult()) .usingRecursiveComparison() - .comparingOnlyFields("objectType_", "objectId_") + .comparingOnlyFields("type_", "id_") .isEqualTo(managerObject); assertEquals(0, getObjectResponse.getRelationsList().size()); } @@ -156,7 +156,7 @@ void testGetUserWithRelations() throws UninitilizedClientException { // Assert assertThat(getObjectResponse.getResult()) .usingRecursiveComparison() - .comparingOnlyFields("objectType_", "objectId_") + .comparingOnlyFields("type_", "id_") .isEqualTo(managerObject); assertThat(getObjectResponse.getRelationsList()) .usingRecursiveFieldByFieldElementComparatorOnFields("objectId_", "objectType_", "relation_", "subjectId_", "subjectType_") @@ -311,7 +311,7 @@ void testGetGraph() { // Assert assertThat(getGraphResponse.getResultsList()) - .usingRecursiveFieldByFieldElementComparatorOnFields("objectId_", "objectType_", "relation_", "subjectId_", "subjectType_") + .usingRecursiveFieldByFieldElementComparatorOnFields("objectType_", "objectId_") .containsExactlyInAnyOrderElementsOf(objectDependencyList); } @@ -430,9 +430,8 @@ void importDataTest() throws InterruptedException, UninitilizedClientException { // Assert GetObjectsResponse getObjectsResponse = directoryClient.getObjects("user"); assertThat(getObjectsResponse.getResultsList()) - .usingRecursiveFieldByFieldElementComparatorOnFields("objectId_", "objectType_", "relation_", "subjectId_", "subjectType_") + .usingRecursiveFieldByFieldElementComparatorOnFields("type_", "id_") .containsAll(users); - } @Test diff --git a/src/test/java/utils/IntegrationTestsExtenion.java b/src/test/java/utils/IntegrationTestsExtension.java similarity index 90% rename from src/test/java/utils/IntegrationTestsExtenion.java rename to src/test/java/utils/IntegrationTestsExtension.java index 99564cd..f6ae443 100644 --- a/src/test/java/utils/IntegrationTestsExtenion.java +++ b/src/test/java/utils/IntegrationTestsExtension.java @@ -8,7 +8,7 @@ import static org.junit.jupiter.api.extension.ExtensionContext.Namespace.GLOBAL; -public class IntegrationTestsExtenion implements BeforeAllCallback, ExtensionContext.Store.CloseableResource { +public class IntegrationTestsExtension implements BeforeAllCallback, ExtensionContext.Store.CloseableResource { private static boolean started = false; private static Topaz topaz; diff --git a/src/test/java/utils/Topaz.java b/src/test/java/utils/Topaz.java index 87db55c..763bf9b 100644 --- a/src/test/java/utils/Topaz.java +++ b/src/test/java/utils/Topaz.java @@ -13,7 +13,7 @@ public class Topaz { private String HOME_DIR = System.getProperty("user.home"); - private String DB_DIR = HOME_DIR + "/.config/topaz/db"; + private String DB_DIR = HOME_DIR + "/.local/share/topaz/db"; private String TOPAZ_CFG_DIR = HOME_DIR + "/.config/topaz/cfg"; private DirectoryClient directoryClient; @@ -35,78 +35,86 @@ public void run() throws IOException, InterruptedException, URISyntaxException { } public void stop() throws IOException, InterruptedException { - Process process = new ProcessBuilder("topaz","stop").start(); + ProcessBuilder pb = new ProcessBuilder("topaz","stop"); + pb.inheritIO(); + Process process = pb.start(); process.waitFor(); restoreDb(); restoreCfg(); } private void start() throws IOException, InterruptedException { - ProcessBuilder pb = new ProcessBuilder("topaz","start"); + ProcessBuilder pb = new ProcessBuilder("topaz","start","--wait"); pb.inheritIO(); Process process = pb.start(); process.waitFor(); - process.waitFor(); - - final Duration timeout = Duration.ofSeconds(60); - ExecutorService executor = Executors.newSingleThreadExecutor(); - - final Future handler = executor.submit(new Callable() { - @Override - public Integer call() throws Exception { - while (true) { - try { - directoryClient.getObjects("user"); - } catch (Exception e) { - Thread.sleep(2000); - continue; - } - - return directoryClient.getObjects("user").getResultsList().size(); - } - } - }); - - try { - handler.get(timeout.toMillis(), TimeUnit.MILLISECONDS); - } catch (TimeoutException | InterruptedException | ExecutionException e) { - handler.cancel(true); - } + // final Duration timeout = Duration.ofSeconds(60); + // ExecutorService executor = Executors.newSingleThreadExecutor(); + + // final Future handler = executor.submit(new Callable() { + // @Override + // public Integer call() throws Exception { + // while (true) { + // try { + // directoryClient.getObjects("user"); + // } catch (Exception e) { + // Thread.sleep(2000); + // continue; + // } + + // return directoryClient.getObjects("user").getResultsList().size(); + // } + // } + // }); + + // try { + // handler.get(timeout.toMillis(), TimeUnit.MILLISECONDS); + // } catch (TimeoutException | InterruptedException | ExecutionException e) { + // handler.cancel(true); + // } } private void configure() throws IOException, InterruptedException { - ProcessBuilder pb = new ProcessBuilder("topaz", "configure", "-r", "ghcr.io/aserto-policies/policy-todo:2.1.0", "-n", "todo", "-d", "-f"); - pb.inheritIO(); - Process process = pb.start(); - process.waitFor(); + { + ProcessBuilder pb = new ProcessBuilder("topaz", "config", "new", "--name", "todo-test", "--resource", "ghcr.io/aserto-policies/policy-todo:2.1.0", "--force"); + pb.inheritIO(); + Process process = pb.start(); + process.waitFor(); + } + { + ProcessBuilder pb = new ProcessBuilder("topaz", "config", "use", "todo-test"); + pb.inheritIO(); + Process process = pb.start(); + process.waitFor(); + } } private void backupDb() { - File directoryDb = new File(DB_DIR + "/directory.db" ); + File directoryDb = new File(DB_DIR + "/todo-test.db" ); if(directoryDb.exists()) { - directoryDb.renameTo(new File(DB_DIR + "/directory.db.bak" )); + directoryDb.renameTo(new File(DB_DIR + "/todo-test.db.bak" )); } } private void restoreDb() { - File directoryDb = new File(DB_DIR + "/directory.db.bak" ); + File directoryDb = new File(DB_DIR + "/todo-test.db.bak" ); if(directoryDb.exists()) { - directoryDb.renameTo(new File(DB_DIR + "/directory.db" )); + directoryDb.renameTo(new File(DB_DIR + "/todo-test.db" )); } } private void backupCfg() { - File directoryDb = new File(TOPAZ_CFG_DIR + "/config.yaml" ); + File directoryDb = new File(TOPAZ_CFG_DIR + "/todo-test.yaml" ); if(directoryDb.exists()) { - directoryDb.renameTo(new File(TOPAZ_CFG_DIR + "/config.yaml.bak" )); + directoryDb.renameTo(new File(TOPAZ_CFG_DIR + "/todo-test.yaml.bak" )); } } private void restoreCfg() { - File directoryDb = new File(TOPAZ_CFG_DIR + "/config.yaml.bak" ); + File directoryDb = new File(TOPAZ_CFG_DIR + "/todo-test.yaml.bak" ); if(directoryDb.exists()) { - directoryDb.renameTo(new File(TOPAZ_CFG_DIR + "/config.yaml" )); + directoryDb.renameTo(new File(TOPAZ_CFG_DIR + "/todo-test.yaml" )); } } }