Skip to content

feat: Add tests for AUTH_REQUIRED#684

Open
kabir wants to merge 2 commits intoa2aproject:mainfrom
kabir:authrequired
Open

feat: Add tests for AUTH_REQUIRED#684
kabir wants to merge 2 commits intoa2aproject:mainfrom
kabir:authrequired

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Feb 25, 2026

Fixes #504 🦕

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kabir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces robust support for the AUTH_REQUIRED task state, enabling agents to request authentication from clients without blocking the ongoing task execution. The changes ensure that tasks requiring authentication can return an immediate response to the client while continuing their work in the background. This behavior is thoroughly validated through a comprehensive suite of new integration tests that cover various aspects of the AUTH_REQUIRED workflow, from event handling to state persistence and client interaction.

Highlights

  • Enhanced AUTH_REQUIRED Handling: The DefaultRequestHandler was updated to recognize and properly handle tasks in the AUTH_REQUIRED state. This ensures that such tasks return immediately to the client while their background execution continues, preventing unnecessary blocking.
  • Comprehensive Integration Tests for AUTH_REQUIRED: A new dedicated test suite, DefaultRequestHandlerTest, was introduced to thoroughly validate the AUTH_REQUIRED workflow. These tests cover scenarios such as immediate return, queue persistence, TaskStore state transitions, streaming behavior, and client resubscription after an authentication request.
  • Result Aggregator Integration: The ResultAggregatorTest was extended with new test cases to confirm that AUTH_REQUIRED events correctly trigger an interrupt in the event consumption process, ensuring proper handling in both blocking and non-blocking contexts.
  • End-to-End Workflow Validation: An end-to-end integration test, testAuthRequiredWorkflow, was added to AbstractA2AServerTest to verify the complete lifecycle of an AUTH_REQUIRED task, from initial request to background completion after simulated out-of-band authentication.
  • Test Agent Behavior Simulation: The AgentExecutorProducer was modified to include special logic for auth-required-test tasks, allowing it to simulate the emission of an AUTH_REQUIRED state and a subsequent delay for out-of-band authentication, crucial for testing the new workflow.
Changelog
  • server-common/src/main/java/io/a2a/server/requesthandlers/DefaultRequestHandler.java
    • Modified the onMessageSend method to identify tasks in TASK_STATE_AUTH_REQUIRED.
    • Updated the blocking condition to exclude AUTH_REQUIRED tasks from being interrupted, allowing them to continue background processing.
  • server-common/src/test/java/io/a2a/server/requesthandlers/DefaultRequestHandlerTest.java
    • Added a new test class DefaultRequestHandlerTest to specifically test the AUTH_REQUIRED workflow.
    • Included tests for non-streaming immediate return, queue remaining open, TaskStore persistence, streaming with background continuation, and resubscription after AUTH_REQUIRED.
  • server-common/src/test/java/io/a2a/server/tasks/ResultAggregatorTest.java
    • Added assertFalse import to the test class.
    • Introduced new test methods (testConsumeAndBreakOnAuthRequired_Blocking, testConsumeAndBreakOnAuthRequired_NonBlocking, testAuthRequiredWithTaskStatusUpdateEvent, testAuthRequiredWithTaskEvent) to verify AUTH_REQUIRED interrupt behavior in the ResultAggregator.
  • tests/server-common/src/test/java/io/a2a/server/apps/common/AbstractA2AServerTest.java
    • Added a new integration test testAuthRequiredWorkflow to validate the end-to-end AUTH_REQUIRED flow, including immediate client response and background task completion.
  • tests/server-common/src/test/java/io/a2a/server/apps/common/AgentExecutorProducer.java
    • Implemented special handling for tasks with IDs starting with 'auth-required-test' to simulate the AUTH_REQUIRED state and an out-of-band authentication delay for testing purposes.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive tests for the AUTH_REQUIRED workflow and implements the necessary logic to support it. The changes are well-structured, and the tests cover various scenarios, including non-streaming, streaming, and resubscription cases. My review includes a critical fix for a bug in a new integration test and a minor refactoring for code conciseness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Add tests for Tasks in AUTH_REQUIRED state

1 participant