diff --git a/.licenses/go/github.com/arduino/iot-client-go/v3.dep.yml b/.licenses/go/github.com/arduino/iot-client-go/v3.dep.yml index 070abedd..76c2942d 100644 --- a/.licenses/go/github.com/arduino/iot-client-go/v3.dep.yml +++ b/.licenses/go/github.com/arduino/iot-client-go/v3.dep.yml @@ -1,6 +1,6 @@ --- name: github.com/arduino/iot-client-go/v3 -version: v3.0.1 +version: v3.1.1 type: go summary: homepage: https://pkg.go.dev/github.com/arduino/iot-client-go/v3 diff --git a/.licenses/go/golang.org/x/oauth2.dep.yml b/.licenses/go/golang.org/x/oauth2.dep.yml index fec14f35..704a67c4 100644 --- a/.licenses/go/golang.org/x/oauth2.dep.yml +++ b/.licenses/go/golang.org/x/oauth2.dep.yml @@ -1,6 +1,6 @@ --- name: golang.org/x/oauth2 -version: v0.23.0 +version: v0.25.0 type: go summary: Package oauth2 provides support for making OAuth2 authorized and authenticated HTTP requests, as specified in RFC 6749. diff --git a/.licenses/go/golang.org/x/oauth2/clientcredentials.dep.yml b/.licenses/go/golang.org/x/oauth2/clientcredentials.dep.yml index 8421ec51..8ecbb7d7 100644 --- a/.licenses/go/golang.org/x/oauth2/clientcredentials.dep.yml +++ b/.licenses/go/golang.org/x/oauth2/clientcredentials.dep.yml @@ -1,13 +1,13 @@ --- name: golang.org/x/oauth2/clientcredentials -version: v0.23.0 +version: v0.25.0 type: go summary: Package clientcredentials implements the OAuth2.0 "client credentials" token flow, also known as the "two-legged OAuth 2.0". homepage: https://pkg.go.dev/golang.org/x/oauth2/clientcredentials license: bsd-3-clause licenses: -- sources: oauth2@v0.23.0/LICENSE +- sources: oauth2@v0.25.0/LICENSE text: | Copyright 2009 The Go Authors. diff --git a/.licenses/go/golang.org/x/oauth2/internal.dep.yml b/.licenses/go/golang.org/x/oauth2/internal.dep.yml index 7267f93c..183fc7e3 100644 --- a/.licenses/go/golang.org/x/oauth2/internal.dep.yml +++ b/.licenses/go/golang.org/x/oauth2/internal.dep.yml @@ -1,12 +1,12 @@ --- name: golang.org/x/oauth2/internal -version: v0.23.0 +version: v0.25.0 type: go summary: Package internal contains support packages for oauth2 package. homepage: https://pkg.go.dev/golang.org/x/oauth2/internal license: bsd-3-clause licenses: -- sources: oauth2@v0.23.0/LICENSE +- sources: oauth2@v0.25.0/LICENSE text: | Copyright 2009 The Go Authors. diff --git a/command/device/show.go b/command/device/show.go index 18d53c77..38fa01d1 100644 --- a/command/device/show.go +++ b/command/device/show.go @@ -58,7 +58,12 @@ func Show(ctx context.Context, deviceId string, cred *config.Credentials) (*Devi return nil, net, err } for _, netCred := range netCredentialsArray { - net = append(net, netCredentials(netCred)) + var netCredToShow netCredentials + netCredToShow.FriendlyName = netCred.FriendlyName + netCredToShow.Required = netCred.Required + netCredToShow.SecretName = netCred.SecretName + netCredToShow.Sensitive = netCred.Sensitive + net = append(net, netCredToShow) } } diff --git a/go.mod b/go.mod index 9b6fd915..e57b7f98 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/arduino/arduino-cli v0.0.0-20240927141754-d9dd4ba1ed71 github.com/arduino/go-paths-helper v1.12.1 github.com/arduino/go-win32-utils v1.0.0 - github.com/arduino/iot-client-go/v3 v3.0.1 + github.com/arduino/iot-client-go/v3 v3.1.1 github.com/gofrs/uuid v4.2.0+incompatible github.com/google/go-cmp v0.6.0 github.com/howeyc/crc16 v0.0.0-20171223171357-2b2a61e366a6 @@ -19,7 +19,7 @@ require ( go.bug.st/cleanup v1.0.0 go.bug.st/serial v1.6.2 golang.org/x/crypto v0.18.0 - golang.org/x/oauth2 v0.23.0 + golang.org/x/oauth2 v0.25.0 google.golang.org/grpc v1.61.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible diff --git a/go.sum b/go.sum index 8f7e0be0..0601b9a9 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/arduino/go-properties-orderedmap v1.7.1 h1:HQ9Pn/mk3+XyfrE39EEvaZwJkr github.com/arduino/go-properties-orderedmap v1.7.1/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk= github.com/arduino/go-win32-utils v1.0.0 h1:/cXB86sOJxOsCHP7sQmXGLkdValwJt56mIwOHYxgQjQ= github.com/arduino/go-win32-utils v1.0.0/go.mod h1:0jqM7doGEAs6DaJCxxhLBUDS5OawrqF48HqXkcEie/Q= -github.com/arduino/iot-client-go/v3 v3.0.1 h1:AwkctEtP7ilVXBOF2yZPJZpjpuUmKNGr/OdYxPx/4QQ= -github.com/arduino/iot-client-go/v3 v3.0.1/go.mod h1:r2QEAP5Jalkr0YWNPhFl0EJzFRQNy24wN5CVbn11f64= +github.com/arduino/iot-client-go/v3 v3.1.1 h1:bQhbV5PlH8tDuSmeimw9Rjrh5KbIUhqvYWWI/xYMi1M= +github.com/arduino/iot-client-go/v3 v3.1.1/go.mod h1:r2QEAP5Jalkr0YWNPhFl0EJzFRQNy24wN5CVbn11f64= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= @@ -582,8 +582,8 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= +golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/internal/iot/client_test.go b/internal/iot/client_test.go new file mode 100644 index 00000000..4c13608c --- /dev/null +++ b/internal/iot/client_test.go @@ -0,0 +1,41 @@ +package iot + +import ( + "testing" + + iotclient "github.com/arduino/iot-client-go/v3" + "github.com/stretchr/testify/assert" +) + +func TestJSON_UnknownFields_areAccepted(t *testing.T) { + + cert := iotclient.ArduinoDevicev2Cert{} + + // Add unknown fields to the JSON and verify that marshalling and unmarshalling works without raising error. + // This is useful when the API is extended with new fields and the client is not updated yet. + certJson := `{ + "compressed": { + "not_after": "0001-01-01T00:00:00Z", + "not_before": "0001-01-01T00:00:00Z", + "serial": "", + "signature": "signature", + "signature_asn1_x": "", + "signature_asn1_y": "" + }, + "der": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA", + "device_id": "123", + "enabled": true, + "href": "", + "id": "", + "pem": "-----BEGIN CERTIFICATE-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA", + "unknown_field": "value", + "unknown_field2": "value2", + "new_api_field": 2222 + }` + + err := cert.UnmarshalJSON([]byte(certJson)) + if err != nil { + t.Errorf("UnmarshalJSON failed: %s", err) + } + assert.Equal(t, 3, len(cert.AdditionalProperties)) +} diff --git a/internal/template/load_test.go b/internal/template/load_test.go index 88bdc931..53d275ec 100644 --- a/internal/template/load_test.go +++ b/internal/template/load_test.go @@ -68,9 +68,10 @@ var ( Widgets: []iotclient.Widget{ {Name: toStringPointer("Switch-name"), Height: 1, HeightMobile: toInt64Pointer(2), Width: 3, WidthMobile: toInt64Pointer(4), X: 5, XMobile: toInt64Pointer(6), Y: 7, YMobile: toInt64Pointer(8), Options: map[string]interface{}{"showLabels": true}, - Type: "Switch", + Type: "Switch", AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardNoOptions = &iotclient.Dashboardv2{ @@ -78,9 +79,10 @@ var ( Widgets: []iotclient.Widget{ {Name: toStringPointer("Switch-name"), Height: 1, HeightMobile: toInt64Pointer(2), Width: 3, WidthMobile: toInt64Pointer(4), X: 5, XMobile: toInt64Pointer(6), Y: 7, YMobile: toInt64Pointer(8), Options: map[string]interface{}{}, - Type: "Switch", + Type: "Switch", AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardWithVariable = &iotclient.Dashboardv2{ @@ -88,9 +90,10 @@ var ( Widgets: []iotclient.Widget{ {Name: toStringPointer("Switch-name"), Height: 1, HeightMobile: toInt64Pointer(2), Width: 3, WidthMobile: toInt64Pointer(4), X: 5, XMobile: toInt64Pointer(6), Y: 7, YMobile: toInt64Pointer(8), Options: map[string]interface{}{"showLabels": true}, Type: "Switch", - Variables: []string{switchyID}, + Variables: []string{switchyID}, AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardVariableOverride = &iotclient.Dashboardv2{ @@ -98,9 +101,10 @@ var ( Widgets: []iotclient.Widget{ {Name: toStringPointer("Switch-name"), Height: 1, HeightMobile: toInt64Pointer(2), Width: 3, WidthMobile: toInt64Pointer(4), X: 5, XMobile: toInt64Pointer(6), Y: 7, YMobile: toInt64Pointer(8), Options: map[string]interface{}{"showLabels": true}, Type: "Switch", - Variables: []string{switchyOverriddenID}, + Variables: []string{switchyOverriddenID}, AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardTwoWidgets = &iotclient.Dashboardv2{ @@ -108,13 +112,14 @@ var ( Widgets: []iotclient.Widget{ {Name: toStringPointer("blink_speed"), Height: 7, Width: 8, X: 7, Y: 5, Options: map[string]interface{}{"min": float64(0), "max": float64(5000)}, Type: "Slider", - Variables: []string{blinkSpeedID}, + Variables: []string{blinkSpeedID}, AdditionalProperties: map[string]any{}, }, {Name: toStringPointer("relay_2"), Height: 5, Width: 5, X: 5, Y: 0, Options: map[string]interface{}{"showLabels": true}, Type: "Switch", - Variables: []string{relayID}, + Variables: []string{relayID}, AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } )