feat: adding hash signature field to patches (#1989)

This commit is contained in:
Erick
2024-04-30 14:25:03 -03:00
committed by GitHub
parent b7d5ea7628
commit cd497aa642
3 changed files with 29 additions and 0 deletions
@@ -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;
@@ -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),
};
@@ -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'));
});
});
});
}