Esempio n. 1
0
            public async Task AcceptsSignedPackagesWithKnownCertificates()
            {
                // Arrange
                var signatures = await TestResources.SignedPackageLeaf1Reader.GetSignaturesAsync(CancellationToken.None);

                _packageMock
                .Setup(x => x.IsSignedAsync(It.IsAny <CancellationToken>()))
                .ReturnsAsync(true);
                _packageMock
                .Setup(x => x.GetSignaturesAsync(It.IsAny <CancellationToken>()))
                .ReturnsAsync(signatures);
                _certificates
                .Setup(x => x.GetAll())
                .Returns(new[] { new Certificate {
                                     Thumbprint = TestResources.Leaf1Thumbprint
                                 } }.AsQueryable());

                // Act
                await _target.ValidateAsync(
                    _packageMock.Object,
                    _validation,
                    _message,
                    _cancellationToken);

                // Assert
                Validate(ValidationStatus.Succeeded, PackageSigningStatus.Valid);
            }
            public async Task RejectsZip64Packages()
            {
                // Arrange
                _packageStream = TestResources.GetResourceStream(TestResources.Zip64Package);

                // Act
                var result = await _target.ValidateAsync(
                    _packageKey,
                    _packageStream,
                    _message,
                    _cancellationToken);

                // Assert
                Validate(result, ValidationStatus.Failed, PackageSigningStatus.Invalid);
                var issue = Assert.Single(result.Issues);

                Assert.Equal(ValidationIssueCode.PackageIsZip64, issue.IssueCode);
            }