feat: adding hash signature field to patches (#1989)
This commit is contained in:
+8
@@ -14,6 +14,7 @@ class CreatePatchArtifactRequest {
|
||||
required this.platform,
|
||||
required this.hash,
|
||||
required this.size,
|
||||
this.hashSignature,
|
||||
});
|
||||
|
||||
/// Converts a Map<String, dynamic> to a [CreatePatchArtifactRequest]
|
||||
@@ -32,6 +33,13 @@ class CreatePatchArtifactRequest {
|
||||
/// The hash of the artifact.
|
||||
final String hash;
|
||||
|
||||
/// The signature of the [hash].
|
||||
///
|
||||
/// Patch code signing is an opt in feature, introduced later in the life of
|
||||
/// the product, so when this field is null, the patch does not uses code
|
||||
/// signing.
|
||||
final String? hashSignature;
|
||||
|
||||
/// The size of the artifact in bytes.
|
||||
@JsonKey(fromJson: _parseStringToInt, toJson: _parseIntToString)
|
||||
final int size;
|
||||
|
||||
+3
@@ -21,9 +21,11 @@ CreatePatchArtifactRequest _$CreatePatchArtifactRequestFromJson(
|
||||
hash: $checkedConvert('hash', (v) => v as String),
|
||||
size: $checkedConvert(
|
||||
'size', (v) => CreatePatchArtifactRequest._parseStringToInt(v)),
|
||||
hashSignature: $checkedConvert('hash_signature', (v) => v as String?),
|
||||
);
|
||||
return val;
|
||||
},
|
||||
fieldKeyMap: const {'hashSignature': 'hash_signature'},
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CreatePatchArtifactRequestToJson(
|
||||
@@ -32,6 +34,7 @@ Map<String, dynamic> _$CreatePatchArtifactRequestToJson(
|
||||
'arch': instance.arch,
|
||||
'platform': _$ReleasePlatformEnumMap[instance.platform]!,
|
||||
'hash': instance.hash,
|
||||
'hash_signature': instance.hashSignature,
|
||||
'size': CreatePatchArtifactRequest._parseIntToString(instance.size),
|
||||
};
|
||||
|
||||
|
||||
+18
@@ -15,5 +15,23 @@ void main() {
|
||||
equals(request.toJson()),
|
||||
);
|
||||
});
|
||||
|
||||
group('when there is a hash signature', () {
|
||||
test('can be (de)serialized', () {
|
||||
const request = CreatePatchArtifactRequest(
|
||||
arch: 'arm64',
|
||||
platform: ReleasePlatform.android,
|
||||
hash: '1234',
|
||||
hashSignature: 'Shh',
|
||||
size: 9876,
|
||||
);
|
||||
final instance = CreatePatchArtifactRequest.fromJson(request.toJson());
|
||||
expect(
|
||||
instance.toJson(),
|
||||
equals(request.toJson()),
|
||||
);
|
||||
expect(instance.hashSignature, equals('Shh'));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user