@@ -110,14 +110,14 @@ func TestPublish(t *testing.T) {
110110 clients := new (climocks.ClientsServiceClient )
111111 authn := new (authnMocks.Authentication )
112112 channels := new (chmocks.ChannelsServiceClient )
113- // ctSenmlJSON := "application/senml+json"
114- // ctSenmlCBOR := "application/senml+cbor"
115- // ctJSON := "application/json"
113+ ctSenmlJSON := "application/senml+json"
114+ ctSenmlCBOR := "application/senml+cbor"
115+ ctJSON := "application/json"
116116 clientKey := "client_key"
117- // invalidKey := invalidValue
117+ invalidKey := invalidValue
118118 msg := `[{"n":"current","t":-1,"v":1.6}]`
119- // msgJSON := `{"field1":"val1","field2":"val2"}`
120- // msgCBOR := `81A3616E6763757272656E746174206176FB3FF999999999999A`
119+ msgJSON := `{"field1":"val1","field2":"val2"}`
120+ msgCBOR := `81A3616E6763757272656E746174206176FB3FF999999999999A`
121121 svc , pub := newService (authn , clients , channels )
122122 target := newTargetHTTPServer ()
123123 defer target .Close ()
@@ -141,81 +141,81 @@ func TestPublish(t *testing.T) {
141141 authzErr error
142142 err error
143143 }{
144- // {
145- // desc: "publish message successfully",
146- // domainID: domainID,
147- // chanID: chanID,
148- // msg: msg,
149- // contentType: ctSenmlJSON,
150- // key: clientKey,
151- // status: http.StatusAccepted,
152- // authnRes: &grpcClientsV1.AuthnRes{Id: clientID, Authenticated: true},
153- // authzRes: &grpcChannelsV1.AuthzRes{Authorized: true},
154- // },
155- // {
156- // desc: "publish message with application/senml+cbor content-type",
157- // domainID: domainID,
158- // chanID: chanID,
159- // msg: msgCBOR,
160- // contentType: ctSenmlCBOR,
161- // key: clientKey,
162- // status: http.StatusAccepted,
163- // authnRes: &grpcClientsV1.AuthnRes{Id: clientID, Authenticated: true},
164- // authzRes: &grpcChannelsV1.AuthzRes{Authorized: true},
165- // },
166- // {
167- // desc: "publish message with application/json content-type",
168- // domainID: domainID,
169- // chanID: chanID,
170- // msg: msgJSON,
171- // contentType: ctJSON,
172- // key: clientKey,
173- // status: http.StatusAccepted,
174- // authnRes: &grpcClientsV1.AuthnRes{Id: clientID, Authenticated: true},
175- // authzRes: &grpcChannelsV1.AuthzRes{Authorized: true},
176- // },
177- // {
178- // desc: "publish message with empty key",
179- // domainID: domainID,
180- // chanID: chanID,
181- // msg: msg,
182- // contentType: ctSenmlJSON,
183- // key: "",
184- // status: http.StatusBadRequest,
185- // },
186- // {
187- // desc: "publish message with basic auth",
188- // domainID: domainID,
189- // chanID: chanID,
190- // msg: msg,
191- // contentType: ctSenmlJSON,
192- // key: clientKey,
193- // basicAuth: true,
194- // status: http.StatusAccepted,
195- // authnRes: &grpcClientsV1.AuthnRes{Id: clientID, Authenticated: true},
196- // authzRes: &grpcChannelsV1.AuthzRes{Authorized: true},
197- // },
198- // {
199- // desc: "publish message with invalid key",
200- // domainID: domainID,
201- // chanID: chanID,
202- // msg: msg,
203- // contentType: ctSenmlJSON,
204- // key: invalidKey,
205- // status: http.StatusUnauthorized,
206- // authnRes: &grpcClientsV1.AuthnRes{Authenticated: false},
207- // },
208- // {
209- // desc: "publish message with invalid basic auth",
210- // domainID: domainID,
211- // chanID: chanID,
212- // msg: msg,
213- // contentType: ctSenmlJSON,
214- // key: invalidKey,
215- // basicAuth: true,
216- // status: http.StatusUnauthorized,
217- // authnRes: &grpcClientsV1.AuthnRes{Authenticated: false},
218- // },
144+ {
145+ desc : "publish message successfully" ,
146+ domainID : domainID ,
147+ chanID : chanID ,
148+ msg : msg ,
149+ contentType : ctSenmlJSON ,
150+ key : clientKey ,
151+ status : http .StatusAccepted ,
152+ authnRes : & grpcClientsV1.AuthnRes {Id : clientID , Authenticated : true },
153+ authzRes : & grpcChannelsV1.AuthzRes {Authorized : true },
154+ },
155+ {
156+ desc : "publish message with application/senml+cbor content-type" ,
157+ domainID : domainID ,
158+ chanID : chanID ,
159+ msg : msgCBOR ,
160+ contentType : ctSenmlCBOR ,
161+ key : clientKey ,
162+ status : http .StatusAccepted ,
163+ authnRes : & grpcClientsV1.AuthnRes {Id : clientID , Authenticated : true },
164+ authzRes : & grpcChannelsV1.AuthzRes {Authorized : true },
165+ },
166+ {
167+ desc : "publish message with application/json content-type" ,
168+ domainID : domainID ,
169+ chanID : chanID ,
170+ msg : msgJSON ,
171+ contentType : ctJSON ,
172+ key : clientKey ,
173+ status : http .StatusAccepted ,
174+ authnRes : & grpcClientsV1.AuthnRes {Id : clientID , Authenticated : true },
175+ authzRes : & grpcChannelsV1.AuthzRes {Authorized : true },
176+ },
177+ {
178+ desc : "publish message with empty key" ,
179+ domainID : domainID ,
180+ chanID : chanID ,
181+ msg : msg ,
182+ contentType : ctSenmlJSON ,
183+ key : "" ,
184+ status : http .StatusBadRequest ,
185+ },
186+ {
187+ desc : "publish message with basic auth" ,
188+ domainID : domainID ,
189+ chanID : chanID ,
190+ msg : msg ,
191+ contentType : ctSenmlJSON ,
192+ key : clientKey ,
193+ basicAuth : true ,
194+ status : http .StatusAccepted ,
195+ authnRes : & grpcClientsV1.AuthnRes {Id : clientID , Authenticated : true },
196+ authzRes : & grpcChannelsV1.AuthzRes {Authorized : true },
197+ },
198+ {
199+ desc : "publish message with invalid key" ,
200+ domainID : domainID ,
201+ chanID : chanID ,
202+ msg : msg ,
203+ contentType : ctSenmlJSON ,
204+ key : invalidKey ,
205+ status : http .StatusUnauthorized ,
206+ authnRes : & grpcClientsV1.AuthnRes {Authenticated : false },
207+ },
208+ {
209+ desc : "publish message with invalid basic auth" ,
210+ domainID : domainID ,
211+ chanID : chanID ,
212+ msg : msg ,
213+ contentType : ctSenmlJSON ,
214+ key : invalidKey ,
215+ basicAuth : true ,
216+ status : http .StatusUnauthorized ,
217+ authnRes : & grpcClientsV1.AuthnRes {Authenticated : false },
218+ },
219219 {
220220 desc : "publish message without content type" ,
221221 domainID : domainID ,
@@ -227,28 +227,28 @@ func TestPublish(t *testing.T) {
227227 authnRes : & grpcClientsV1.AuthnRes {Id : clientID , Authenticated : true },
228228 authzRes : & grpcChannelsV1.AuthzRes {Authorized : true },
229229 },
230- // {
231- // desc: "publish message to empty channel",
232- // domainID: domainID,
233- // chanID: "",
234- // msg: msg,
235- // contentType: ctSenmlJSON,
236- // key: clientKey,
237- // status: http.StatusBadRequest,
238- // authnRes: &grpcClientsV1.AuthnRes{Id: clientID, Authenticated: true},
239- // authzRes: &grpcChannelsV1.AuthzRes{Authorized: false},
240- // },
241- // {
242- // desc: "publish message with invalid domain ID",
243- // domainID: invalidValue,
244- // chanID: chanID,
245- // msg: msg,
246- // contentType: ctSenmlJSON,
247- // key: clientKey,
248- // status: http.StatusUnauthorized,
249- // authnRes: &grpcClientsV1.AuthnRes{Id: clientID, Authenticated: true},
250- // authzRes: &grpcChannelsV1.AuthzRes{Authorized: false},
251- // },
230+ {
231+ desc : "publish message to empty channel" ,
232+ domainID : domainID ,
233+ chanID : "" ,
234+ msg : msg ,
235+ contentType : ctSenmlJSON ,
236+ key : clientKey ,
237+ status : http .StatusBadRequest ,
238+ authnRes : & grpcClientsV1.AuthnRes {Id : clientID , Authenticated : true },
239+ authzRes : & grpcChannelsV1.AuthzRes {Authorized : false },
240+ },
241+ {
242+ desc : "publish message with invalid domain ID" ,
243+ domainID : invalidValue ,
244+ chanID : chanID ,
245+ msg : msg ,
246+ contentType : ctSenmlJSON ,
247+ key : clientKey ,
248+ status : http .StatusUnauthorized ,
249+ authnRes : & grpcClientsV1.AuthnRes {Id : clientID , Authenticated : true },
250+ authzRes : & grpcChannelsV1.AuthzRes {Authorized : false },
251+ },
252252 }
253253
254254 for _ , tc := range cases {
0 commit comments