(t *testing.T)
| 37 | ) |
| 38 | |
| 39 | func TestGetAppSKey(t *testing.T) { //nolint:paralleltest |
| 40 | for _, tc := range []struct { //nolint:paralleltest |
| 41 | Name string |
| 42 | NewServer func(*assertions.Assertion) *httptest.Server |
| 43 | AsID string |
| 44 | Request *ttnpb.SessionKeyRequest |
| 45 | ResponseAssertion func(*assertions.Assertion, *ttnpb.AppSKeyResponse) bool |
| 46 | ErrorAssertion func(*assertions.Assertion, error) bool |
| 47 | }{ |
| 48 | { |
| 49 | Name: "Backend Interfaces 1.0/UnknownDevEUI", |
| 50 | NewServer: func(a *assertions.Assertion) *httptest.Server { |
| 51 | return newTLSServer(9183, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 52 | a.So(r.Method, should.Equal, http.MethodPost) |
| 53 | b := test.Must(io.ReadAll(r.Body)) |
| 54 | var req map[string]any |
| 55 | test.Must[any](nil, json.Unmarshal(b, &req)) |
| 56 | a.So(req, should.Resemble, map[string]any{ |
| 57 | "ProtocolVersion": "1.0", |
| 58 | "TransactionID": 0.0, |
| 59 | "MessageType": "AppSKeyReq", |
| 60 | "SenderID": "test-as", |
| 61 | "ReceiverID": "70B3D57ED0000000", |
| 62 | "DevEUI": "0102030405060708", |
| 63 | "SessionKeyID": "016BFA7BAD4756346A674981E75CDBDC", |
| 64 | }) |
| 65 | test.Must[any](nil, json.NewEncoder(w).Encode(map[string]any{ |
| 66 | "ProtocolVersion": "1.0", |
| 67 | "TransactionID": 0.0, |
| 68 | "MessageType": "AppSKeyAns", |
| 69 | "SenderID": "70B3D57ED0000000", |
| 70 | "ReceiverID": "test-as", |
| 71 | "Result": map[string]any{ |
| 72 | "ResultCode": "UnknownDevEUI", |
| 73 | }, |
| 74 | })) |
| 75 | })) |
| 76 | }, |
| 77 | AsID: "test-as", |
| 78 | Request: &ttnpb.SessionKeyRequest{ |
| 79 | JoinEui: types.EUI64{0x70, 0xb3, 0xd5, 0x7e, 0xd0, 0x00, 0x00, 0x00}.Bytes(), |
| 80 | DevEui: types.EUI64{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}.Bytes(), |
| 81 | SessionKeyId: []byte{0x01, 0x6b, 0xfa, 0x7b, 0xad, 0x47, 0x56, 0x34, 0x6a, 0x67, 0x49, 0x81, 0xe7, 0x5c, 0xdb, 0xdc}, //nolint:lll |
| 82 | }, |
| 83 | ResponseAssertion: func(a *assertions.Assertion, resp *ttnpb.AppSKeyResponse) bool { |
| 84 | return a.So(resp, should.BeNil) |
| 85 | }, |
| 86 | ErrorAssertion: func(a *assertions.Assertion, err error) bool { |
| 87 | return a.So(err, should.HaveSameErrorDefinitionAs, ErrUnknownDevEUI) |
| 88 | }, |
| 89 | }, |
| 90 | { |
| 91 | Name: "Backend Interfaces 1.1/UnknownDevEUI", |
| 92 | NewServer: func(a *assertions.Assertion) *httptest.Server { |
| 93 | return newTLSServer(9183, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 94 | a := a |
| 95 | a.So(r.Method, should.Equal, http.MethodPost) |
| 96 | b := test.Must(io.ReadAll(r.Body)) |
nothing calls this directly
no test coverage detected