From 224231a213b4a56cae13ff5b9b98069e4a79abbd Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Thu, 30 Jan 2025 17:34:41 +0100 Subject: [PATCH 1/6] Clients update --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 9b6fd91..25f7bdc 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.0 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 8f7e0be..0f51ce9 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.0 h1:xHKdlpXshfk9PiqV3RLs6754iLo0AWSepFlgLqSn9Xc= +github.com/arduino/iot-client-go/v3 v3.1.0/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= From 30aaea2e52df108a4726b06754a6656d882ce72d Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Thu, 30 Jan 2025 17:37:04 +0100 Subject: [PATCH 2/6] Updated licenses --- .licenses/go/github.com/arduino/iot-client-go/v3.dep.yml | 2 +- .licenses/go/golang.org/x/oauth2.dep.yml | 2 +- .licenses/go/golang.org/x/oauth2/clientcredentials.dep.yml | 4 ++-- .licenses/go/golang.org/x/oauth2/internal.dep.yml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) 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 070abed..61706eb 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.0 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 fec14f3..704a67c 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 8421ec5..8ecbb7d 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 7267f93..183fc7e 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. From f7ebb13d7f8ee22bf85d347a08e57acf9c0a8c9d Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 31 Jan 2025 08:12:03 +0100 Subject: [PATCH 3/6] Moving to clients v3.1.1 --- .licenses/go/github.com/arduino/iot-client-go/v3.dep.yml | 2 +- command/device/show.go | 7 ++++++- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) 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 61706eb..76c2942 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.1.0 +version: v3.1.1 type: go summary: homepage: https://pkg.go.dev/github.com/arduino/iot-client-go/v3 diff --git a/command/device/show.go b/command/device/show.go index 18d53c7..38fa01d 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 25f7bdc..e57b7f9 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.1.0 + 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 diff --git a/go.sum b/go.sum index 0f51ce9..0601b9a 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.1.0 h1:xHKdlpXshfk9PiqV3RLs6754iLo0AWSepFlgLqSn9Xc= -github.com/arduino/iot-client-go/v3 v3.1.0/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= From 290039d810dacb462eca1c0016aa2f5175a4fa84 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 31 Jan 2025 08:21:41 +0100 Subject: [PATCH 4/6] Fix for test --- internal/template/load_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/template/load_test.go b/internal/template/load_test.go index 88bdc93..abfb99e 100644 --- a/internal/template/load_test.go +++ b/internal/template/load_test.go @@ -68,7 +68,7 @@ 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{}, }, }, } @@ -78,7 +78,7 @@ 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{}, }, }, } @@ -88,7 +88,7 @@ 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{}, }, }, } @@ -98,7 +98,7 @@ 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{}, }, }, } @@ -108,11 +108,11 @@ 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{}, }, }, } From 324ebb2c251ca8eb2fa296a2b37e8044c77ba7d3 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 31 Jan 2025 08:25:24 +0100 Subject: [PATCH 5/6] fix model check --- internal/template/load_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/template/load_test.go b/internal/template/load_test.go index abfb99e..53d275e 100644 --- a/internal/template/load_test.go +++ b/internal/template/load_test.go @@ -71,6 +71,7 @@ var ( Type: "Switch", AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardNoOptions = &iotclient.Dashboardv2{ @@ -81,6 +82,7 @@ var ( Type: "Switch", AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardWithVariable = &iotclient.Dashboardv2{ @@ -91,6 +93,7 @@ var ( Variables: []string{switchyID}, AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardVariableOverride = &iotclient.Dashboardv2{ @@ -101,6 +104,7 @@ var ( Variables: []string{switchyOverriddenID}, AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } dashboardTwoWidgets = &iotclient.Dashboardv2{ @@ -115,6 +119,7 @@ var ( Variables: []string{relayID}, AdditionalProperties: map[string]any{}, }, }, + AdditionalProperties: map[string]any{}, } ) From bd88501f9c9fc45c2e89859d813efcb384abf3e3 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 31 Jan 2025 08:43:15 +0100 Subject: [PATCH 6/6] Added new test --- internal/iot/client_test.go | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 internal/iot/client_test.go diff --git a/internal/iot/client_test.go b/internal/iot/client_test.go new file mode 100644 index 0000000..4c13608 --- /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)) +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy