@@ -48,8 +48,52 @@ def handle_request(request); end
4848 @session . instance_variable_set ( :@client_capabilities , { elicitation : { } } )
4949 end
5050
51+ test "#create_form_elicitation warns when called without related_request_id" do
52+ # Per SEP-2260, server-to-client requests must be associated with an originating client request.
53+ # `$VERBOSE = false` because the rake test task runs with `-W0`, under which `Kernel#warn` emits nothing.
54+ original_verbose = $VERBOSE
55+ $VERBOSE = false
56+
57+ assert_output ( nil , /SEP-2260/ ) do
58+ @session . create_form_elicitation (
59+ message : "Please provide your name" ,
60+ requested_schema : { type : "object" , properties : { name : { type : "string" } } } ,
61+ )
62+ end
63+ ensure
64+ $VERBOSE = original_verbose
65+ end
66+
67+ test "#create_url_elicitation warns when called without related_request_id" do
68+ @session . instance_variable_set ( :@client_capabilities , { elicitation : { url : true } } )
69+
70+ original_verbose = $VERBOSE
71+ $VERBOSE = false
72+
73+ assert_output ( nil , /SEP-2260/ ) do
74+ @session . create_url_elicitation (
75+ message : "Please sign in" ,
76+ url : "https://example.com/signin" ,
77+ elicitation_id : "el-1" ,
78+ )
79+ end
80+ ensure
81+ $VERBOSE = original_verbose
82+ end
83+
84+ test "#create_form_elicitation does not warn when related_request_id is given" do
85+ assert_silent do
86+ @session . create_form_elicitation (
87+ related_request_id : "req-1" ,
88+ message : "Please provide your name" ,
89+ requested_schema : { type : "object" , properties : { name : { type : "string" } } } ,
90+ )
91+ end
92+ end
93+
5194 test "#create_form_elicitation sends request through transport" do
5295 result = @session . create_form_elicitation (
96+ related_request_id : "req-1" ,
5397 message : "Please provide your name" ,
5498 requested_schema : {
5599 type : "object" ,
@@ -76,6 +120,7 @@ def handle_request(request); end
76120
77121 error = assert_raises ( RuntimeError ) do
78122 @session . create_form_elicitation (
123+ related_request_id : "req-1" ,
79124 message : "Please provide your name" ,
80125 requested_schema : { type : "object" , properties : { name : { type : "string" } } } ,
81126 )
@@ -93,6 +138,7 @@ def handle_request(request); end
93138
94139 error = assert_raises ( RuntimeError ) do
95140 @session . create_form_elicitation (
141+ related_request_id : "req-1" ,
96142 message : "Please provide your name" ,
97143 requested_schema : { type : "object" , properties : { name : { type : "string" } } } ,
98144 )
@@ -108,6 +154,7 @@ def handle_request(request); end
108154 @session . instance_variable_set ( :@client_capabilities , { elicitation : { url : { } } } )
109155
110156 result = @session . create_url_elicitation (
157+ related_request_id : "req-1" ,
111158 message : "Please authorize access" ,
112159 url : "https://example.com/oauth" ,
113160 elicitation_id : "abc-123" ,
@@ -128,6 +175,7 @@ def handle_request(request); end
128175 test "#create_url_elicitation raises error when client does not support url mode" do
129176 error = assert_raises ( RuntimeError ) do
130177 @session . create_url_elicitation (
178+ related_request_id : "req-1" ,
131179 message : "Please authorize access" ,
132180 url : "https://example.com/oauth" ,
133181 elicitation_id : "abc-123" ,
@@ -146,6 +194,7 @@ def handle_request(request); end
146194
147195 error = assert_raises ( RuntimeError ) do
148196 @session . create_url_elicitation (
197+ related_request_id : "req-1" ,
149198 message : "Please authorize access" ,
150199 url : "https://example.com/oauth" ,
151200 elicitation_id : "abc-123" ,
0 commit comments