Remove unknown field assertion from awsCatalogPersistedStateFromProto
This commit is contained in:
2 files changed
-23
No files matched your search
@@ -100,29 +100,20 @@ func awsCatalogPersistedStateFromProto(in *pb.HostCatalogPersisted, opts ...awsC
|
||||
return nil, errors.New("missing persisted secrets")
|
||||
}
|
||||
|
||||
unknownFields := structFields(data)
|
||||
|
||||
accessKeyId, err := getStringValue(data, constAccessKeyId, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("persisted state integrity error: %w", err)
|
||||
}
|
||||
delete(unknownFields, constAccessKeyId)
|
||||
|
||||
secretAccessKey, err := getStringValue(data, constSecretAccessKey, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("persisted state integrity error: %w", err)
|
||||
}
|
||||
delete(unknownFields, constSecretAccessKey)
|
||||
|
||||
credsLastRotatedTime, err := getTimeValue(data, constCredsLastRotatedTime)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("persisted state integrity error: %w", err)
|
||||
}
|
||||
delete(unknownFields, constCredsLastRotatedTime)
|
||||
|
||||
if len(unknownFields) != 0 {
|
||||
return nil, errors.New("one or more unrecognized persisted secret attributes found")
|
||||
}
|
||||
|
||||
s, err := newAwsCatalogPersistedState(opts...)
|
||||
if err != nil {
|
||||
|
||||
@@ -168,20 +168,6 @@ func TestAwsCatalogPersistedStateFromProto(t *testing.T) {
|
||||
},
|
||||
expectedErr: testOptionErr,
|
||||
},
|
||||
{
|
||||
name: "unknown fields",
|
||||
in: &pb.HostCatalogPersisted{
|
||||
// Nil should be the same as empty map here
|
||||
Secrets: mustStruct(map[string]interface{}{
|
||||
constAccessKeyId: "foobar",
|
||||
constSecretAccessKey: "bazqux",
|
||||
constCredsLastRotatedTime: (time.Time{}).Format(time.RFC3339Nano),
|
||||
"foo": true,
|
||||
"bar": true,
|
||||
}),
|
||||
},
|
||||
expectedErr: "one or more unrecognized persisted secret attributes found",
|
||||
},
|
||||
{
|
||||
name: "good with non-zero timestamp",
|
||||
in: &pb.HostCatalogPersisted{
|
||||
|
||||
Reference in new issue
Block a user