mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-07-27 22:38:30 +08:00
* Add workload identity federation support to base-action Move the workload identity module into base-action so the standalone action can fetch and refresh the GitHub OIDC identity token itself, and expose the same federation inputs as the outer action. Switch the base-action test workflows from the anthropic_api_key secret to the federation repo variables and grant them id-token: write. * Verify MCP test tool invocation instead of init connection status MCP servers can connect asynchronously, so the init event may report a server as pending. Check that the server is registered at init, then assert the test tool was actually called and returned its response. Also pass the MCP config through claude_args --mcp-config, replacing the removed mcp_config input.
195 lines
6.5 KiB
YAML
195 lines
6.5 KiB
YAML
name: Test Settings Feature
|
|
|
|
on:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
|
|
# The Claude API is authenticated via workload identity federation: id-token
|
|
# lets the action mint the GitHub OIDC token it exchanges for a short-lived
|
|
# access token. See docs/setup.md.
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
jobs:
|
|
test-settings-inline-allow:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
|
|
- name: Test with inline settings JSON (echo allowed)
|
|
id: inline-settings-test
|
|
uses: ./base-action
|
|
with:
|
|
prompt: |
|
|
Use Bash to echo "Hello from settings test"
|
|
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
|
|
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
|
|
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
|
|
settings: |
|
|
{
|
|
"permissions": {
|
|
"allow": ["Bash(echo:*)"]
|
|
}
|
|
}
|
|
|
|
- name: Verify echo worked
|
|
run: |
|
|
OUTPUT_FILE="${{ steps.inline-settings-test.outputs.execution_file }}"
|
|
CONCLUSION="${{ steps.inline-settings-test.outputs.conclusion }}"
|
|
|
|
echo "Conclusion: $CONCLUSION"
|
|
|
|
if [ "$CONCLUSION" = "success" ]; then
|
|
echo "✅ Action completed successfully"
|
|
else
|
|
echo "❌ Action failed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check that permission was NOT denied
|
|
if grep -q "Permission to use Bash with command echo.*has been denied" "$OUTPUT_FILE"; then
|
|
echo "❌ Echo command was denied when it should have been allowed"
|
|
cat "$OUTPUT_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if the echo command worked
|
|
if grep -q "Hello from settings test" "$OUTPUT_FILE"; then
|
|
echo "✅ Bash echo command worked (allowed by permissions)"
|
|
else
|
|
echo "❌ Bash echo command didn't work"
|
|
cat "$OUTPUT_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
test-settings-inline-deny:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
|
|
- name: Test with inline settings JSON (echo denied)
|
|
id: inline-settings-test
|
|
uses: ./base-action
|
|
with:
|
|
prompt: |
|
|
Run the command `echo $HOME` to check the home directory path
|
|
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
|
|
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
|
|
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
|
|
settings: |
|
|
{
|
|
"permissions": {
|
|
"deny": ["Bash(echo:*)"]
|
|
}
|
|
}
|
|
|
|
- name: Verify echo was denied
|
|
run: |
|
|
OUTPUT_FILE="${{ steps.inline-settings-test.outputs.execution_file }}"
|
|
|
|
# Check that permission was denied in the tool_result
|
|
if grep -q "Permission to use Bash with command echo.*has been denied" "$OUTPUT_FILE"; then
|
|
echo "✅ Echo command was correctly denied by permissions"
|
|
else
|
|
echo "❌ Expected permission denied message not found"
|
|
cat "$OUTPUT_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
test-settings-file-allow:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
|
|
- name: Create settings file (echo allowed)
|
|
run: |
|
|
cat > test-settings.json << EOF
|
|
{
|
|
"permissions": {
|
|
"allow": ["Bash(echo:*)"]
|
|
}
|
|
}
|
|
EOF
|
|
|
|
- name: Test with settings file
|
|
id: file-settings-test
|
|
uses: ./base-action
|
|
with:
|
|
prompt: |
|
|
Use Bash to echo "Hello from settings file test"
|
|
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
|
|
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
|
|
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
|
|
settings: "test-settings.json"
|
|
|
|
- name: Verify echo worked
|
|
run: |
|
|
OUTPUT_FILE="${{ steps.file-settings-test.outputs.execution_file }}"
|
|
CONCLUSION="${{ steps.file-settings-test.outputs.conclusion }}"
|
|
|
|
echo "Conclusion: $CONCLUSION"
|
|
|
|
if [ "$CONCLUSION" = "success" ]; then
|
|
echo "✅ Action completed successfully"
|
|
else
|
|
echo "❌ Action failed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check that permission was NOT denied
|
|
if grep -q "Permission to use Bash with command echo.*has been denied" "$OUTPUT_FILE"; then
|
|
echo "❌ Echo command was denied when it should have been allowed"
|
|
cat "$OUTPUT_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if the echo command worked
|
|
if grep -q "Hello from settings file test" "$OUTPUT_FILE"; then
|
|
echo "✅ Bash echo command worked (allowed by permissions)"
|
|
else
|
|
echo "❌ Bash echo command didn't work"
|
|
cat "$OUTPUT_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
test-settings-file-deny:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
|
|
- name: Create settings file (echo denied)
|
|
run: |
|
|
cat > test-settings.json << EOF
|
|
{
|
|
"permissions": {
|
|
"deny": ["Bash(echo:*)"]
|
|
}
|
|
}
|
|
EOF
|
|
|
|
- name: Test with settings file
|
|
id: file-settings-test
|
|
uses: ./base-action
|
|
with:
|
|
prompt: |
|
|
Run the command `echo $HOME` to check the home directory path
|
|
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
|
|
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
|
|
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
|
|
settings: "test-settings.json"
|
|
|
|
- name: Verify echo was denied
|
|
run: |
|
|
OUTPUT_FILE="${{ steps.file-settings-test.outputs.execution_file }}"
|
|
|
|
# Check that permission was denied in the tool_result
|
|
if grep -q "Permission to use Bash with command echo.*has been denied" "$OUTPUT_FILE"; then
|
|
echo "✅ Echo command was correctly denied by permissions"
|
|
else
|
|
echo "❌ Expected permission denied message not found"
|
|
cat "$OUTPUT_FILE"
|
|
exit 1
|
|
fi
|