Merge pull request 'Test structured prompts and guard trusted releases' (#1) from test/structured-async-payload-alpha7 into main
This commit is contained in:
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -7,6 +7,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
push:
|
push:
|
||||||
|
if: ${{ github.server_url == 'https://github.com' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|||||||
@@ -126,6 +126,57 @@ class SmokeTest < Minitest::Test
|
|||||||
assert_equal({}, response)
|
assert_equal({}, response)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_send_message_async_serializes_a_structured_child_prompt
|
||||||
|
schema = {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
requirement_suggestions: {
|
||||||
|
type: "array",
|
||||||
|
items: { type: "string" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
required: [ "requirement_suggestions" ],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
invocation_query =
|
||||||
|
"Complete the bounded structured request from the preloaded worker skill and immutable Rails context."
|
||||||
|
expected_body = {
|
||||||
|
messageID: "msg_worker_1",
|
||||||
|
parts: [ { type: "text", text: invocation_query } ],
|
||||||
|
agent: "destination-list-curator",
|
||||||
|
format: {
|
||||||
|
type: "json_schema",
|
||||||
|
schema: schema,
|
||||||
|
retryCount: 0
|
||||||
|
},
|
||||||
|
system: "Immutable Rails context"
|
||||||
|
}
|
||||||
|
serialized_body = nil
|
||||||
|
|
||||||
|
prompt = stub_request(:post, "#{BASE}/session/#{SESSION_ID}/prompt_async")
|
||||||
|
.with(body: expected_body.to_json)
|
||||||
|
.to_return do |request|
|
||||||
|
serialized_body = request.body
|
||||||
|
{ status: 204, body: "" }
|
||||||
|
end
|
||||||
|
|
||||||
|
@client.send_message_async(
|
||||||
|
SESSION_ID,
|
||||||
|
invocation_query,
|
||||||
|
agent: "destination-list-curator",
|
||||||
|
system: "Immutable Rails context",
|
||||||
|
message_id: "msg_worker_1",
|
||||||
|
format: {
|
||||||
|
type: "json_schema",
|
||||||
|
schema: schema,
|
||||||
|
retryCount: 0
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
assert_equal expected_body.to_json, serialized_body
|
||||||
|
assert_requested prompt, times: 1
|
||||||
|
end
|
||||||
|
|
||||||
def test_stream_returns_typed_Reply_Result_with_full_text
|
def test_stream_returns_typed_Reply_Result_with_full_text
|
||||||
stub_request(:post, "#{BASE}/session/#{SESSION_ID}/prompt_async")
|
stub_request(:post, "#{BASE}/session/#{SESSION_ID}/prompt_async")
|
||||||
.to_return(status: 204, body: "")
|
.to_return(status: 204, body: "")
|
||||||
|
|||||||
33
test/release_workflow_test.rb
Normal file
33
test/release_workflow_test.rb
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "minitest/autorun"
|
||||||
|
require "yaml"
|
||||||
|
|
||||||
|
class ReleaseWorkflowTest < Minitest::Test
|
||||||
|
ROOT = File.expand_path("..", __dir__)
|
||||||
|
WORKFLOW_PATH = File.join(ROOT, ".github", "workflows", "release.yml")
|
||||||
|
|
||||||
|
def workflow
|
||||||
|
@workflow ||= YAML.safe_load(File.read(WORKFLOW_PATH), aliases: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def push_job
|
||||||
|
workflow.fetch("jobs").fetch("push")
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_release_job_is_inert_on_non_github_runners
|
||||||
|
assert_equal "${{ github.server_url == 'https://github.com' }}", push_job.fetch("if")
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_release_job_keeps_the_trusted_publisher_boundary
|
||||||
|
assert_equal "release", push_job.fetch("environment")
|
||||||
|
assert_equal(
|
||||||
|
{ "contents" => "write", "id-token" => "write" },
|
||||||
|
push_job.fetch("permissions")
|
||||||
|
)
|
||||||
|
|
||||||
|
steps = push_job.fetch("steps")
|
||||||
|
assert_equal 1, steps.count { |step| step["uses"] == "rubygems/release-gem@v1" }
|
||||||
|
refute steps.any? { |step| step.fetch("run", "").match?(/\bgem\s+push\b/) }
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user