Ejemplo n.º 1
0
        public async Task HasRepositoryCountersignature_WithSignatureWithRepositoryCountersignature_ReturnsTrueAsync()
        {
            using (var certificate = _fixture.GetDefaultCertificate())
                using (var repositoryCertificate = _fixture.GetDefaultCertificate())
                {
                    var packageContext        = new SimpleTestPackageContext();
                    var unsignedPackageStream = packageContext.CreateAsStream();

                    var signature = await SignedArchiveTestUtility.CreatePrimarySignatureForPackageAsync(
                        certificate,
                        unsignedPackageStream);

                    var reposignedSignature = await SignedArchiveTestUtility.RepositoryCountersignPrimarySignatureAsync(repositoryCertificate, signature);

                    var hasRepoCountersignature = SignatureUtility.HasRepositoryCountersignature(reposignedSignature);

                    Assert.True(hasRepoCountersignature);
                }
        }
Ejemplo n.º 2
0
        public async Task HasRepositoryCountersignature_WithSignatureWithRepositoryCountersignature_ReturnsTrueAsync()
        {
            using (var certificate = _fixture.GetDefaultCertificate())
                using (var repositoryCertificate = _fixture.GetDefaultCertificate())
                {
                    var packageContext        = new SimpleTestPackageContext();
                    var unsignedPackageStream = packageContext.CreateAsStream();

                    var signature = await SignedArchiveTestUtility.CreateAuthorSignatureForPackageAsync(
                        certificate,
                        unsignedPackageStream);

                    var hashAlgorithm     = Common.HashAlgorithmName.SHA256;
                    var v3ServiceIndexUri = new Uri("https://v3serviceIndex.test/api/index.json");
                    using (var request = new RepositorySignPackageRequest(repositoryCertificate, hashAlgorithm, hashAlgorithm, v3ServiceIndexUri, null))
                    {
                        var reposignedSignature = await SignedArchiveTestUtility.RepositoryCountersignPrimarySignatureAsync(signature, request);

                        var hasRepoCountersignature = SignatureUtility.HasRepositoryCountersignature(reposignedSignature);

                        Assert.True(hasRepoCountersignature);
                    }
                }
        }