@@ -63,12 +63,21 @@ def test_receive_json(data)
6363 def test_receive_compressed_json
6464 d = create_driver
6565 res = d . run ( expect_records : 1 ) do
66- post_json ( "/v1/metrics " , compress ( TestData ::JSON ::METRICS ) , { "Content-Encoding" => "gzip" } )
66+ post_json ( "/v1/logs " , compress ( TestData ::JSON ::LOGS ) , { "Content-Encoding" => "gzip" } )
6767 end
6868
6969 assert_equal ( 200 , res . status )
7070 assert_equal ( "otlp.test" , d . events [ 0 ] [ 0 ] )
71- assert_equal ( { type : "otlp_metrics" , message : TestData ::JSON ::METRICS } , d . events [ 0 ] [ 2 ] )
71+ assert_equal ( { type : "otlp_logs" , message : TestData ::JSON ::LOGS } , d . events [ 0 ] [ 2 ] )
72+ end
73+
74+ def test_invalid_json
75+ d = create_driver
76+ res = d . run ( expect_records : 0 ) do
77+ post_json ( "/v1/logs" , TestData ::JSON ::INVALID )
78+ end
79+
80+ assert_equal ( 400 , res . status )
7281 end
7382
7483 data ( "metrics" => {
@@ -103,12 +112,39 @@ def test_receive_protocol_buffers(data)
103112 def test_receive_compressed_protocol_buffers
104113 d = create_driver
105114 res = d . run ( expect_records : 1 ) do
106- post_json ( "/v1/metrics " , compress ( TestData ::ProtocolBuffers ::METRICS ) , { "Content-Encoding" => "gzip" } )
115+ post_json ( "/v1/logs " , compress ( TestData ::ProtocolBuffers ::LOGS ) , { "Content-Encoding" => "gzip" } )
107116 end
108117
109118 assert_equal ( 200 , res . status )
110119 assert_equal ( "otlp.test" , d . events [ 0 ] [ 0 ] )
111- assert_equal ( { type : "otlp_metrics" , message : TestData ::JSON ::METRICS } , d . events [ 0 ] [ 2 ] )
120+ assert_equal ( { type : "otlp_logs" , message : TestData ::JSON ::LOGS } , d . events [ 0 ] [ 2 ] )
121+ end
122+
123+ def test_invalid_protocol_buffers
124+ d = create_driver
125+ res = d . run ( expect_records : 0 ) do
126+ post_json ( "/v1/logs" , TestData ::ProtocolBuffers ::INVALID )
127+ end
128+
129+ assert_equal ( 400 , res . status )
130+ end
131+
132+ def test_invalid_content_type
133+ d = create_driver
134+ res = d . run ( expect_records : 0 ) do
135+ post ( "/v1/logs" , TestData ::JSON ::LOGS , { "Content-Type" => "text/plain" } )
136+ end
137+
138+ assert_equal ( 415 , res . status )
139+ end
140+
141+ def test_invalid_content_encoding
142+ d = create_driver
143+ res = d . run ( expect_records : 0 ) do
144+ post_json ( "/v1/logs" , TestData ::JSON ::LOGS , { "Content-Encoding" => "deflate" } )
145+ end
146+
147+ assert_equal ( 400 , res . status )
112148 end
113149
114150 def compress ( data )
0 commit comments