public void TestBuild() { TestCalculateDigest(); TestDetectCandidates(); TestGenerateCommands(); _builder.RetrievalMethod = new Archive(); _builder.Uri = new FeedUri("http://0install.de/feeds/test/test1.xml"); _builder.Icons.Add(new Icon { MimeType = Icon.MimeTypePng, Href = new Uri("http://0install.de/test.png") }); _builder.Icons.Add(new Icon { MimeType = Icon.MimeTypeIco, Href = new Uri("http://0install.de/test.ico") }); _builder.SecretKey = new OpenPgpSecretKey("fingerprint", "key", "user", new DateTime(2000, 1, 1), OpenPgpAlgorithm.Rsa, 1024); var signedFeed = _builder.Build(); Assert.AreEqual(expected: _builder.MainCandidate.Name, actual: signedFeed.Feed.Name); Assert.AreEqual(expected: _builder.Uri, actual: signedFeed.Feed.Uri); CollectionAssert.AreEqual( expected: new LocalizableStringCollection { _builder.MainCandidate.Summary }, actual: signedFeed.Feed.Summaries); Assert.AreEqual(expected: _builder.MainCandidate.NeedsTerminal, actual: signedFeed.Feed.NeedsTerminal); CollectionAssert.AreEqual( expected: new[] { new Implementation { ID = "sha1new=" + ManifestDigest.Empty.Sha1New, ManifestDigest = ManifestDigest.Empty, Version = _builder.MainCandidate.Version, Architecture = _builder.MainCandidate.Architecture, Commands = { new Command { Name = Command.NameRun, Path = "test" } }, RetrievalMethods = { _builder.RetrievalMethod } } }, actual: signedFeed.Feed.Elements); CollectionAssert.AreEqual(expected: _builder.Icons, actual: signedFeed.Feed.Icons); CollectionAssert.IsEmpty(signedFeed.Feed.EntryPoints, "Should not generate entry points if there is only a single command"); Assert.AreEqual(expected: _builder.SecretKey, actual: signedFeed.SecretKey); }
public void TestBuild() { TestGenerateDigest(); TestDetectCandidates(); TestGenerateCommands(); _builder.RetrievalMethod = new Archive(); _builder.Uri = new FeedUri("http://example.com/test1.xml"); _builder.Icons.Add(new Icon { MimeType = Icon.MimeTypePng, Href = new Uri("http://example.com/test.png") }); _builder.Icons.Add(new Icon { MimeType = Icon.MimeTypeIco, Href = new Uri("http://example.com/test.ico") }); _builder.SecretKey = new OpenPgpSecretKey(keyID: 123, fingerprint: new byte[] { 1, 2, 3 }, userID: "user"); var signedFeed = _builder.Build(); signedFeed.Feed.Name.Should().Be(_builder.MainCandidate.Name); signedFeed.Feed.Uri.Should().Be(_builder.Uri); signedFeed.Feed.Summaries.Should().Equal(new LocalizableStringCollection { _builder.MainCandidate.Summary }); signedFeed.Feed.NeedsTerminal.Should().Be(_builder.MainCandidate.NeedsTerminal); signedFeed.Feed.Elements.Should().Equal( new Implementation { ID = "sha1new=" + ManifestDigest.Empty.Sha1New, ManifestDigest = new ManifestDigest(sha256New: ManifestDigest.Empty.Sha256New), Version = _builder.MainCandidate.Version, Architecture = _builder.MainCandidate.Architecture, Commands = { new Command { Name = Command.NameRun, Path = "test" } }, RetrievalMethods = { _builder.RetrievalMethod } }); signedFeed.Feed.Icons.Should().Equal(_builder.Icons); signedFeed.SecretKey.Should().Be(_builder.SecretKey); }
private ExitCode Finish() { if (_additionalArgs.Count != 3) return PrintHelp(); string snapshotFile = _additionalArgs[1]; string feedFile = _additionalArgs[2]; if (FileExists(feedFile)) return ExitCode.IOError; var feedBuilder = new FeedBuilder(); var session = CaptureSession.Load(snapshotFile, feedBuilder); session.InstallationDir = _installationDirectory; session.Diff(_handler); feedBuilder.MainCandidate = string.IsNullOrEmpty(_mainExe) ? feedBuilder.Candidates.FirstOrDefault() : feedBuilder.Candidates.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(FileUtils.UnifySlashes(x.RelativePath), _mainExe)); session.Finish(); if (!string.IsNullOrEmpty(_zipFile)) { if (FileExists(_zipFile)) return ExitCode.IOError; var relativeUri = new Uri(Path.GetFullPath(feedFile)).MakeRelativeUri(new Uri(Path.GetFullPath(_zipFile))); session.CollectFiles(_zipFile, relativeUri, _handler); Log.Warn("If you wish to upload this feed and ZIP archive, make sure to turn the <archive>'s relative href into an absolute one."); } feedBuilder.Build().Save(feedFile); return ExitCode.OK; }