diff --git a/.github/workflows/test-osrh-auth.yaml b/.github/workflows/test-osrh-auth.yaml new file mode 100644 index 00000000..a0d56cbc --- /dev/null +++ b/.github/workflows/test-osrh-auth.yaml @@ -0,0 +1,86 @@ +name: Test OSSRH Authentication +on: + workflow_dispatch: # Manual trigger only + pull_request: + branches: + - main + +jobs: + test-auth: + runs-on: ubuntu-latest + steps: + - name: Check out src from Git + uses: actions/checkout@v4 + + - name: Debug - Check secrets availability + run: | + echo "Testing if secrets are available:" + if [ -n "${{ secrets.OSSRH_USERNAME }}" ]; then + echo "✓ OSSRH_USERNAME is available" + else + echo "✗ OSSRH_USERNAME is missing" + fi + if [ -n "${{ secrets.OSSRH_TOKEN }}" ]; then + echo "✓ OSSRH_TOKEN is available" + else + echo "✗ OSSRH_TOKEN is missing" + fi + + - name: Test OSSRH API connection + run: | + echo "Testing OSSRH API connection..." + response=$(curl -s -w "%{http_code}" -u "${{ secrets.OSSRH_USERNAME }}:${{ secrets.OSSRH_TOKEN }}" \ + -H "Accept: application/json" \ + https://oss.sonatype.org/service/local/user/profile) + + http_code="${response: -3}" + body="${response%???}" + + echo "HTTP Status Code: $http_code" + echo "Response body: $body" + + if [ "$http_code" = "200" ]; then + echo "✓ Successfully authenticated with OSSRH" + else + echo "✗ Failed to authenticate with OSSRH (HTTP $http_code)" + exit 1 + fi + + - name: Test staging repository access + run: | + echo "Testing staging repository access..." + response=$(curl -s -w "%{http_code}" -u "${{ secrets.OSSRH_USERNAME }}:${{ secrets.OSSRH_TOKEN }}" \ + -H "Accept: application/json" \ + https://oss.sonatype.org/service/local/staging/profile_repositories) + + http_code="${response: -3}" + body="${response%???}" + + echo "HTTP Status Code: $http_code" + echo "Response body: $body" + + if [ "$http_code" = "200" ]; then + echo "✓ Successfully accessed staging repositories" + else + echo "✗ Failed to access staging repositories (HTTP $http_code)" + exit 1 + fi + + - name: Check group ID permissions + run: | + echo "Checking permissions for group ID: com.spotify.confidence" + response=$(curl -s -w "%{http_code}" -u "${{ secrets.OSSRH_USERNAME }}:${{ secrets.OSSRH_TOKEN }}" \ + -H "Accept: application/json" \ + https://oss.sonatype.org/service/local/staging/profiles) + + http_code="${response: -3}" + body="${response%???}" + + echo "HTTP Status Code: $http_code" + if echo "$body" | grep -q "com.spotify.confidence"; then + echo "✓ Found staging profile for com.spotify.confidence" + else + echo "✗ No staging profile found for com.spotify.confidence" + echo "Available profiles:" + echo "$body" | jq -r '.data[] | .name + " (" + .id + ")"' 2>/dev/null || echo "$body" + fi \ No newline at end of file diff --git a/.github/workflows/test-osrh-token.yaml b/.github/workflows/test-osrh-token.yaml new file mode 100644 index 00000000..432c457c --- /dev/null +++ b/.github/workflows/test-osrh-token.yaml @@ -0,0 +1,65 @@ +name: Test OSSRH Token Validity +on: + pull_request: + branches: + - main + paths: + - '.github/workflows/test-osrh-token.yaml' + +jobs: + test-token: + runs-on: ubuntu-latest + steps: + - name: Test OSSRH Token + run: | + echo "Testing OSSRH token validity..." + + # Test basic authentication + echo "1. Testing basic authentication..." + auth_response=$(curl -s -w "%{http_code}" -u "${{ secrets.OSSRH_USERNAME_2 }}:${{ secrets.OSSRH_TOKEN_2 }}" \ + -H "Accept: application/json" \ + https://oss.sonatype.org/service/local/user/profile) + + auth_http_code="${auth_response: -3}" + auth_body="${auth_response%???}" + + echo "Authentication HTTP Status: $auth_http_code" + + if [ "$auth_http_code" = "200" ]; then + echo "✅ Token is valid - authentication successful" + echo "User profile: $auth_body" + elif [ "$auth_http_code" = "401" ]; then + echo "❌ Token is invalid or expired (401 Unauthorized)" + echo "Please regenerate your OSSRH token" + exit 1 + elif [ "$auth_http_code" = "403" ]; then + echo "❌ Token is valid but lacks permissions (403 Forbidden)" + echo "Check your OSSRH account permissions" + exit 1 + else + echo "❌ Unexpected response: HTTP $auth_http_code" + echo "Response: $auth_body" + exit 1 + fi + + # Test staging access + echo "" + echo "2. Testing staging repository access..." + staging_response=$(curl -s -w "%{http_code}" -u "${{ secrets.OSSRH_USERNAME_2 }}:${{ secrets.OSSRH_TOKEN_2 }}" \ + -H "Accept: application/json" \ + https://oss.sonatype.org/service/local/staging/profile_repositories) + + staging_http_code="${staging_response: -3}" + staging_body="${staging_response%???}" + + echo "Staging HTTP Status: $staging_http_code" + + if [ "$staging_http_code" = "200" ]; then + echo "✅ Staging repository access successful" + else + echo "❌ Staging repository access failed: HTTP $staging_http_code" + echo "Response: $staging_body" + fi + + echo "" + echo "Token validation complete!" \ No newline at end of file