@@ -63,12 +63,21 @@ def test_receive_json(data)
63
63
def test_receive_compressed_json
64
64
d = create_driver
65
65
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" } )
67
67
end
68
68
69
69
assert_equal ( 200 , res . status )
70
70
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 )
72
81
end
73
82
74
83
data ( "metrics" => {
@@ -103,12 +112,39 @@ def test_receive_protocol_buffers(data)
103
112
def test_receive_compressed_protocol_buffers
104
113
d = create_driver
105
114
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" } )
107
116
end
108
117
109
118
assert_equal ( 200 , res . status )
110
119
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 )
112
148
end
113
149
114
150
def compress ( data )
0 commit comments