Skip to content

Commit

Permalink
Merge pull request #2085 from ClickHouse/repo_fix_jwt_tests
Browse files Browse the repository at this point in the history
[repo] Fix JWT tests
  • Loading branch information
chernser authored Jan 14, 2025
2 parents 5995a7e + 88fbe0d commit fa53726
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,17 @@ jobs:
EOF
- name: Install Java client
run: mvn --also-make --batch-mode --no-transfer-progress -DskipTests install
- name: Generate JWT
env:
JWT_K_PEM: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_JWT_PRIVATE_KEY }}
run: |
npm install jsonwebtoken &&
echo "CLIENT_JWT=$(node jwt-gen.js)" >> "$GITHUB_ENV"
# - name: Generate JWT
# env:
# JWT_K_PEM: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_JWT_PRIVATE_KEY }}
# run: |
# npm install jsonwebtoken &&
# echo "CLIENT_JWT=$(node jwt-gen.js)" >> "$GITHUB_ENV"
- name: Test http client
env:
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
CLIENT_JWT: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_JWT_DESERT_VM_43 }}
run: |
mvn --batch-mode --no-transfer-progress --projects ${{ matrix.project }} -DclickhouseVersion=${{ matrix.clickhouse }} -Dprotocol=http verify
- name: Upload test results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -1016,6 +1017,8 @@ public void testJWTWithCloud() throws Exception {
return; // only for cloud
}
String jwt = System.getenv("CLIENT_JWT");
Assert.assertTrue(jwt != null && !jwt.trim().isEmpty(), "JWT is missing");
Assert.assertFalse(jwt.contains("\n") || jwt.contains("-----"), "JWT should be single string ready for HTTP header");
try (Client client = newClient().useBearerTokenAuth(jwt).build()) {
try {
List<GenericRecord> response = client.queryAll("SELECT user(), now()");
Expand Down

0 comments on commit fa53726

Please sign in to comment.