@@ -16,6 +16,13 @@ def get_json(path, headers: {})
1616 perform_request ( uri , request )
1717 end
1818
19+ def get_response ( path , headers : { } )
20+ uri = URI . join ( base_url , path )
21+ request = Net ::HTTP ::Get . new ( uri , headers )
22+ response = Net ::HTTP . start ( uri . host , uri . port ) { |http | http . request ( request ) }
23+ [ response , response . body . to_s ]
24+ end
25+
1926 def post_json ( path , body :, headers : { } )
2027 uri = URI . join ( base_url , path )
2128 request = Net ::HTTP ::Post . new ( uri , headers . merge ( 'Content-Type' => 'application/json' ) )
@@ -28,6 +35,18 @@ def perform_request(uri, request)
2835 [ response , response . body . to_s . empty? ? { } : JSON . parse ( response . body ) ]
2936 end
3037
38+ def expect_created_feed_response ( body )
39+ expect ( body . fetch ( 'success' ) ) . to be ( true )
40+ expect ( body . dig ( 'data' , 'feed' , 'public_url' ) ) . to match ( %r{^/api/v1/feeds/} )
41+ expect ( body . dig ( 'data' , 'feed' , 'json_public_url' ) ) . to match ( %r{^/api/v1/feeds/.+\. json$} )
42+ end
43+
44+ def expect_json_feed_response ( path )
45+ feed_response , = get_response ( path , headers : { 'Accept' => 'application/feed+json' } )
46+ expect ( feed_response [ 'Content-Type' ] ) . to include ( 'application/feed+json' )
47+ expect ( feed_response . code ) . not_to eq ( '401' )
48+ end
49+
3150 it 'exposes health endpoints without authentication requirements' , :aggregate_failures do
3251 response , payload = get_json ( '/api/v1/health/ready' )
3352 expect ( response ) . to be_a ( Net ::HTTPOK )
@@ -72,9 +91,8 @@ def perform_request(uri, request)
7291 headers : { 'Authorization' => "Bearer #{ feed_token } " } )
7392
7493 expect ( response . code ) . to eq ( '201' )
75- expect ( body . fetch ( 'success' ) ) . to be ( true )
76- expect ( body . dig ( 'data' , 'feed' , 'public_url' ) ) . to match ( %r{^/api/v1/feeds/} )
77- expect ( body . dig ( 'data' , 'feed' , 'json_public_url' ) ) . to match ( %r{^/api/v1/feeds/.+\. json$} )
94+ expect_created_feed_response ( body )
95+ expect_json_feed_response ( body . dig ( 'data' , 'feed' , 'json_public_url' ) )
7896 end
7997
8098 it 'returns forbidden for authenticated creation when auto source is disabled' , :aggregate_failures do
0 commit comments