diff --git a/api/publish.go b/api/publish.go index 7775540c4..fc7d72241 100644 --- a/api/publish.go +++ b/api/publish.go @@ -113,7 +113,7 @@ func apiPublishList(c *gin.Context) { func apiPublishShow(c *gin.Context) { param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() @@ -179,7 +179,7 @@ type publishedRepoCreateParams struct { // @Failure 500 {object} Error "Internal Error" // @Router /api/publish/{prefix} [post] func apiPublishRepoOrSnapshot(c *gin.Context) { - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) var b publishedRepoCreateParams @@ -196,7 +196,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) { } if len(b.Sources) == 0 { - AbortWithJSONError(c, http.StatusBadRequest, fmt.Errorf("unable to publish: soures are empty")) + AbortWithJSONError(c, http.StatusBadRequest, fmt.Errorf("unable to publish: sources are empty")) return } @@ -346,7 +346,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) { func apiPublishUpdateSwitch(c *gin.Context) { param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := utils.SanitizePath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) var b struct { ForceOverwrite bool @@ -438,24 +438,19 @@ func apiPublishUpdateSwitch(c *gin.Context) { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err) } - updatedComponents := result.UpdatedComponents() - removedComponents := result.RemovedComponents() - if b.SkipCleanup == nil || !*b.SkipCleanup { publishedStorage := context.GetPublishedStorage(storage) - err = collection.CleanupPrefixComponentFiles(published.Prefix, updatedComponents, publishedStorage, collectionFactory, out) + err = collection.CleanupPrefixComponentFiles(published.Prefix, result.UpdatedComponents(), publishedStorage, collectionFactory, out) if err != nil { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err) } - if len(removedComponents) > 0 { - // Cleanup files belonging to a removed component by dropping the component directory from the storage backend. - for _, component := range removedComponents { - err = publishedStorage.RemoveDirs(filepath.Join(prefix, "dists", distribution, component), out) - if err != nil { - return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err) - } + // Cleanup files belonging to a removed component by dropping the component directory from the storage backend. + for _, component := range result.RemovedComponents() { + err = publishedStorage.RemoveDirs(filepath.Join(prefix, "dists", distribution, component), out) + if err != nil { + return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err) } } } @@ -484,7 +479,7 @@ func apiPublishDrop(c *gin.Context) { param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() @@ -515,9 +510,9 @@ func apiPublishSourcesCreate(c *gin.Context) { b sourceParams ) - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() @@ -560,15 +555,15 @@ func apiPublishSourcesCreate(c *gin.Context) { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err) } - return &task.ProcessReturnValue{Code: http.StatusOK, Value: published}, nil + return &task.ProcessReturnValue{Code: http.StatusCreated, Value: published}, nil }) } // @Router /api/publish/{prefix}/{distribution}/sources [get] func apiPublishSourcesList(c *gin.Context) { - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() @@ -601,9 +596,9 @@ func apiPublishSourcesUpdate(c *gin.Context) { b []sourceParams ) - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() @@ -648,26 +643,37 @@ func apiPublishSourcesUpdate(c *gin.Context) { // @Router /api/publish/{prefix}/{distribution}/sources [delete] func apiPublishSourcesDelete(c *gin.Context) { - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution) if err != nil { - AbortWithJSONError(c, http.StatusNotFound, fmt.Errorf("unable to show: %s", err)) + AbortWithJSONError(c, http.StatusNotFound, fmt.Errorf("unable to delete: %s", err)) return } err = collection.LoadComplete(published, collectionFactory) if err != nil { - AbortWithJSONError(c, http.StatusInternalServerError, fmt.Errorf("unable to show: %s", err)) + AbortWithJSONError(c, http.StatusInternalServerError, fmt.Errorf("unable to delete: %s", err)) return } published.DropRevision() + + resources := []string{string(published.Key())} + taskName := fmt.Sprintf("Update published %s repository %s/%s", published.SourceKind, published.StoragePrefix(), published.Distribution) + maybeRunTaskInBackground(c, taskName, resources, func(out aptly.Progress, _ *task.Detail) (*task.ProcessReturnValue, error) { + err = collection.Update(published) + if err != nil { + return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to save to DB: %s", err) + } + + return &task.ProcessReturnValue{Code: http.StatusOK, Value: published}, nil + }) } // @Router /api/publish/{prefix}/{distribution}/sources/{component} [put] @@ -677,10 +683,10 @@ func apiPublishSourceUpdate(c *gin.Context) { b sourceParams ) - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) - component := parseEscapedPath(c.Params.ByName("component")) + distribution := slashEscape(c.Params.ByName("distribution")) + component := slashEscape(c.Params.ByName("component")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() @@ -737,10 +743,10 @@ func apiPublishSourceUpdate(c *gin.Context) { func apiPublishSourceDelete(c *gin.Context) { var err error - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) - component := parseEscapedPath(c.Params.ByName("component")) + distribution := slashEscape(c.Params.ByName("distribution")) + component := slashEscape(c.Params.ByName("component")) collectionFactory := context.NewCollectionFactory() collection := collectionFactory.PublishedRepoCollection() @@ -776,9 +782,9 @@ func apiPublishSourceDelete(c *gin.Context) { // @Router /api/publish/{prefix}/{distribution}/update [post] func apiPublishUpdate(c *gin.Context) { - param := parseEscapedPath(c.Params.ByName("prefix")) + param := slashEscape(c.Params.ByName("prefix")) storage, prefix := deb.ParsePrefix(param) - distribution := parseEscapedPath(c.Params.ByName("distribution")) + distribution := slashEscape(c.Params.ByName("distribution")) var b struct { AcquireByHash *bool diff --git a/cmd/publish_source_add.go b/cmd/publish_source_add.go index 08adeb772..2ee9e7fff 100644 --- a/cmd/publish_source_add.go +++ b/cmd/publish_source_add.go @@ -56,6 +56,9 @@ func aptlyPublishSourceAdd(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to save to DB: %s", err) } + context.Progress().Printf("\nYou can run 'aptly publish update %s %s' to update the content of the published repository.\n", + distribution, published.StoragePrefix()) + return err } @@ -63,9 +66,9 @@ func makeCmdPublishSourceAdd() *commander.Command { cmd := &commander.Command{ Run: aptlyPublishSourceAdd, UsageLine: "add ", - Short: "add package source to published repository", + Short: "add source to staged source list of published repository", Long: ` -The command adds (in place) one or multiple package sources to a published repository. +The command adds sources to the staged source list of the published repository. The flag -component is mandatory. Use a comma-separated list of components, if multiple components should be modified. The number of given components must be diff --git a/cmd/publish_source_drop.go b/cmd/publish_source_drop.go index af5c1f842..d038e0e45 100644 --- a/cmd/publish_source_drop.go +++ b/cmd/publish_source_drop.go @@ -45,13 +45,13 @@ func makeCmdPublishSourceDrop() *commander.Command { cmd := &commander.Command{ Run: aptlyPublishSourceDrop, UsageLine: "drop ", - Short: "drops revision of published repository", + Short: "drops staged source changes of published repository", Long: ` -Command drops revision of a published repository. +Command drops the staged source changes of the published repository. Example: - $ aptly publish revision drop wheezy + $ aptly publish source drop wheezy `, Flag: *flag.NewFlagSet("aptly-publish-revision-create", flag.ExitOnError), } diff --git a/cmd/publish_source_remove.go b/cmd/publish_source_remove.go index 624763b87..1d3892c41 100644 --- a/cmd/publish_source_remove.go +++ b/cmd/publish_source_remove.go @@ -42,7 +42,7 @@ func aptlyPublishSourceRemove(cmd *commander.Command, args []string) error { for _, component := range components { name, exists := sources[component] if !exists { - return fmt.Errorf("unable to remove: Component %q is not part of revision", component) + return fmt.Errorf("unable to remove: component %q does not exist", component) } context.Progress().Printf("Removing component %q with source %q [%s]...\n", component, name, published.SourceKind) @@ -54,6 +54,9 @@ func aptlyPublishSourceRemove(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to save to DB: %s", err) } + context.Progress().Printf("\nYou can run 'aptly publish update %s %s' to update the content of the published repository.\n", + distribution, published.StoragePrefix()) + return err } @@ -61,9 +64,9 @@ func makeCmdPublishSourceRemove() *commander.Command { cmd := &commander.Command{ Run: aptlyPublishSourceRemove, UsageLine: "remove [[:]] ", - Short: "remove package source to published repository", + Short: "remove source from staged source list of published repository", Long: ` -The command removes one or multiple components from a published repository. +The command removes sources from the staged source list of the published repository. The flag -component is mandatory. Use a comma-separated list of components, if multiple components should be removed, e.g.: diff --git a/cmd/publish_source_update.go b/cmd/publish_source_update.go index 9a81fcc98..66c274680 100644 --- a/cmd/publish_source_update.go +++ b/cmd/publish_source_update.go @@ -56,6 +56,9 @@ func aptlyPublishSourceUpdate(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to save to DB: %s", err) } + context.Progress().Printf("\nYou can run 'aptly publish update %s %s' to update the content of the published repository.\n", + distribution, published.StoragePrefix()) + return err } @@ -63,9 +66,9 @@ func makeCmdPublishSourceUpdate() *commander.Command { cmd := &commander.Command{ Run: aptlyPublishSourceUpdate, UsageLine: "update ", - Short: "update package source to published repository", + Short: "update source in staged source list of published repository", Long: ` -The command updates one or multiple components in a published repository. +The command updates sources in the staged source list of the published repository. The flag -component is mandatory. Use a comma-separated list of components, if multiple components should be modified. The number of given components must be diff --git a/cmd/publish_switch.go b/cmd/publish_switch.go index 6d65db722..ab11f5946 100644 --- a/cmd/publish_switch.go +++ b/cmd/publish_switch.go @@ -43,6 +43,10 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to switch: %s", err) } + if published.SourceKind != deb.SourceSnapshot { + return fmt.Errorf("unable to switch: not a published snapshot repository") + } + err = collectionFactory.PublishedRepoCollection().LoadComplete(published, collectionFactory) if err != nil { return fmt.Errorf("unable to switch: %s", err) @@ -57,46 +61,23 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error { return fmt.Errorf("mismatch in number of components (%d) and snapshots (%d)", len(components), len(names)) } - if published.SourceKind == deb.SourceLocalRepo { - localRepoCollection := collectionFactory.LocalRepoCollection() - for i, component := range components { - if !utils.StrSliceHasItem(publishedComponents, component) { - return fmt.Errorf("unable to switch: component %s does not exist in published repository", component) - } - - localRepo, err := localRepoCollection.ByName(names[i]) - if err != nil { - return fmt.Errorf("unable to switch: %s", err) - } - - err = localRepoCollection.LoadComplete(localRepo) - if err != nil { - return fmt.Errorf("unable to switch: %s", err) - } + snapshotCollection := collectionFactory.SnapshotCollection() + for i, component := range components { + if !utils.StrSliceHasItem(publishedComponents, component) { + return fmt.Errorf("unable to switch: component %s does not exist in published repository", component) + } - published.UpdateLocalRepo(component, localRepo) + snapshot, err := snapshotCollection.ByName(names[i]) + if err != nil { + return fmt.Errorf("unable to switch: %s", err) } - } else if published.SourceKind == deb.SourceSnapshot { - snapshotCollection := collectionFactory.SnapshotCollection() - for i, component := range components { - if !utils.StrSliceHasItem(publishedComponents, component) { - return fmt.Errorf("unable to switch: component %s does not exist in published repository", component) - } - - snapshot, err := snapshotCollection.ByName(names[i]) - if err != nil { - return fmt.Errorf("unable to switch: %s", err) - } - - err = snapshotCollection.LoadComplete(snapshot) - if err != nil { - return fmt.Errorf("unable to switch: %s", err) - } - - published.UpdateSnapshot(component, snapshot) + + err = snapshotCollection.LoadComplete(snapshot) + if err != nil { + return fmt.Errorf("unable to switch: %s", err) } - } else { - return fmt.Errorf("unknown published repository type") + + published.UpdateSnapshot(component, snapshot) } signer, err := getSigner(context.Flags()) diff --git a/cmd/publish_update.go b/cmd/publish_update.go index decd4e2bc..da2dba57c 100644 --- a/cmd/publish_update.go +++ b/cmd/publish_update.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "path/filepath" "github.com/aptly-dev/aptly/deb" "github.com/smira/commander" @@ -76,11 +77,20 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error { skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool) if !skipCleanup { + publishedStorage := context.GetPublishedStorage(storage) err = collectionFactory.PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, result.UpdatedComponents(), - context.GetPublishedStorage(storage), collectionFactory, context.Progress()) + publishedStorage, collectionFactory, context.Progress()) if err != nil { return fmt.Errorf("unable to update: %s", err) } + + // Cleanup files belonging to a removed component by dropping the component directory from the storage backend. + for _, component := range result.RemovedComponents() { + err = publishedStorage.RemoveDirs(filepath.Join(prefix, "dists", distribution, component), context.Progress()) + if err != nil { + return fmt.Errorf("unable to update: %s", err) + } + } } context.Progress().Printf("\nPublished %s repository %s has been successfully updated.\n", published.SourceKind, published.String()) diff --git a/deb/publish.go b/deb/publish.go index b900077d9..067f94852 100644 --- a/deb/publish.go +++ b/deb/publish.go @@ -194,69 +194,78 @@ func (p *PublishedRepo) Update(collectionFactory *CollectionFactory, _ aptly.Pro RemovedSources: map[string]string{}, } - revision := p.ObtainRevision() - p.DropRevision() - - publishedComponents := p.Components() - - for _, component := range publishedComponents { - name, exists := revision.Sources[component] - if !exists { - p.RemoveComponent(component) - result.RemovedSources[component] = name + revision := p.DropRevision() + if revision == nil { + if p.SourceKind == SourceLocalRepo { + // Re-fetch packages from local repository + for component, item := range p.sourceItems { + localRepo := item.localRepo + if localRepo != nil { + p.UpdateLocalRepo(component, localRepo) + result.UpdatedSources[component] = localRepo.Name + } + } } - } - - if p.SourceKind == SourceLocalRepo { - localRepoCollection := collectionFactory.LocalRepoCollection() - for component, name := range revision.Sources { - localRepo, err := localRepoCollection.ByName(name) - if err != nil { - return result, fmt.Errorf("unable to update: %s", err) + } else { + for _, component := range p.Components() { + name, exists := revision.Sources[component] + if !exists { + p.RemoveComponent(component) + result.RemovedSources[component] = name } + } - err = localRepoCollection.LoadComplete(localRepo) - if err != nil { - return result, fmt.Errorf("unable to update: %s", err) - } + if p.SourceKind == SourceLocalRepo { + localRepoCollection := collectionFactory.LocalRepoCollection() + for component, name := range revision.Sources { + localRepo, err := localRepoCollection.ByName(name) + if err != nil { + return result, fmt.Errorf("unable to update: %s", err) + } - _, exists := p.Sources[component] - if exists { - // Even in the case, when the local repository has not been changed as package source, - // it may contain a modified set of packages that requires (re-)publication. - p.UpdateLocalRepo(component, localRepo) - result.UpdatedSources[component] = name - } else { - p.UpdateLocalRepo(component, localRepo) - result.AddedSources[component] = name - } - } - } else if p.SourceKind == SourceSnapshot { - snapshotCollection := collectionFactory.SnapshotCollection() - for component, name := range revision.Sources { - snapshot, err := snapshotCollection.ByName(name) - if err != nil { - return result, fmt.Errorf("unable to update: %s", err) - } + err = localRepoCollection.LoadComplete(localRepo) + if err != nil { + return result, fmt.Errorf("unable to update: %s", err) + } - err = snapshotCollection.LoadComplete(snapshot) - if err != nil { - return result, fmt.Errorf("unable to update: %s", err) + _, exists := p.Sources[component] + if exists { + // Even in the case, when the local repository has not been changed as package source, + // it may contain a modified set of packages that requires (re-)publication. + p.UpdateLocalRepo(component, localRepo) + result.UpdatedSources[component] = name + } else { + p.UpdateLocalRepo(component, localRepo) + result.AddedSources[component] = name + } } + } else if p.SourceKind == SourceSnapshot { + snapshotCollection := collectionFactory.SnapshotCollection() + for component, name := range revision.Sources { + snapshot, err := snapshotCollection.ByName(name) + if err != nil { + return result, fmt.Errorf("unable to update: %s", err) + } - sourceUUID, exists := p.Sources[component] - if exists { - if snapshot.UUID != sourceUUID { + err = snapshotCollection.LoadComplete(snapshot) + if err != nil { + return result, fmt.Errorf("unable to update: %s", err) + } + + sourceUUID, exists := p.Sources[component] + if exists { + if snapshot.UUID != sourceUUID { + p.UpdateSnapshot(component, snapshot) + result.UpdatedSources[component] = name + } + } else { p.UpdateSnapshot(component, snapshot) - result.UpdatedSources[component] = name + result.AddedSources[component] = name } - } else { - p.UpdateSnapshot(component, snapshot) - result.AddedSources[component] = name } + } else { + return result, fmt.Errorf("unknown published repository type") } - } else { - return result, fmt.Errorf("unknown published repository type") } return result, nil diff --git a/system/t06_publish/PublishSourceAdd1Test_gold b/system/t06_publish/PublishSourceAdd1Test_gold index 345e6aef7..8ac95d375 100644 --- a/system/t06_publish/PublishSourceAdd1Test_gold +++ b/system/t06_publish/PublishSourceAdd1Test_gold @@ -1 +1,3 @@ -Test +Adding component "test" with source "snap2" [snapshot]... + +You can run 'aptly publish update maverick .' to update the content of the published repository. diff --git a/system/t06_publish/PublishSourceAdd2Test_gold b/system/t06_publish/PublishSourceAdd2Test_gold index 345e6aef7..904bfc81d 100644 --- a/system/t06_publish/PublishSourceAdd2Test_gold +++ b/system/t06_publish/PublishSourceAdd2Test_gold @@ -1 +1,4 @@ -Test +Adding component "test" with source "snap2" [snapshot]... +Adding component "other-test" with source "snap3" [snapshot]... + +You can run 'aptly publish update maverick .' to update the content of the published repository. diff --git a/system/t06_publish/PublishSourceAdd3Test_gold b/system/t06_publish/PublishSourceAdd3Test_gold index 345e6aef7..e5802b783 100644 --- a/system/t06_publish/PublishSourceAdd3Test_gold +++ b/system/t06_publish/PublishSourceAdd3Test_gold @@ -1 +1 @@ -Test +ERROR: unable to add: component "main" has already been added diff --git a/system/t06_publish/PublishSourceDrop1Test_gold b/system/t06_publish/PublishSourceDrop1Test_gold index 345e6aef7..5f05ba78c 100644 --- a/system/t06_publish/PublishSourceDrop1Test_gold +++ b/system/t06_publish/PublishSourceDrop1Test_gold @@ -1 +1 @@ -Test +Source changes have been removed successfully. diff --git a/system/t06_publish/PublishSourceList1Test_gold b/system/t06_publish/PublishSourceList1Test_gold index 345e6aef7..364ef5c2d 100644 --- a/system/t06_publish/PublishSourceList1Test_gold +++ b/system/t06_publish/PublishSourceList1Test_gold @@ -1 +1,3 @@ -Test +Sources: + main: snap1 [snapshot] + test: snap2 [snapshot] diff --git a/system/t06_publish/PublishSourceList2Test_gold b/system/t06_publish/PublishSourceList2Test_gold new file mode 100644 index 000000000..ba30e4af5 --- /dev/null +++ b/system/t06_publish/PublishSourceList2Test_gold @@ -0,0 +1,10 @@ +[ + { + "Component": "main", + "Name": "snap1" + }, + { + "Component": "test", + "Name": "snap2" + } +] diff --git a/system/t06_publish/PublishSourceList3Test_gold b/system/t06_publish/PublishSourceList3Test_gold new file mode 100644 index 000000000..03e2a99a8 --- /dev/null +++ b/system/t06_publish/PublishSourceList3Test_gold @@ -0,0 +1 @@ +ERROR: unable to list: no source changes exist diff --git a/system/t06_publish/PublishSourceRemove1Test_gold b/system/t06_publish/PublishSourceRemove1Test_gold index 345e6aef7..761bf16b3 100644 --- a/system/t06_publish/PublishSourceRemove1Test_gold +++ b/system/t06_publish/PublishSourceRemove1Test_gold @@ -1 +1,3 @@ -Test +Removing component "test" with source "snap2" [snapshot]... + +You can run 'aptly publish update maverick .' to update the content of the published repository. diff --git a/system/t06_publish/PublishSourceRemove2Test_gold b/system/t06_publish/PublishSourceRemove2Test_gold index 345e6aef7..6692ca2ed 100644 --- a/system/t06_publish/PublishSourceRemove2Test_gold +++ b/system/t06_publish/PublishSourceRemove2Test_gold @@ -1 +1,4 @@ -Test +Removing component "test" with source "snap2" [snapshot]... +Removing component "other-test" with source "snap3" [snapshot]... + +You can run 'aptly publish update maverick .' to update the content of the published repository. diff --git a/system/t06_publish/PublishSourceRemove3Test_gold b/system/t06_publish/PublishSourceRemove3Test_gold index 345e6aef7..54507f259 100644 --- a/system/t06_publish/PublishSourceRemove3Test_gold +++ b/system/t06_publish/PublishSourceRemove3Test_gold @@ -1 +1 @@ -Test +ERROR: unable to remove: component "not-existent" does not exist diff --git a/system/t06_publish/PublishSourceUpdate1Test_gold b/system/t06_publish/PublishSourceUpdate1Test_gold index 345e6aef7..ea66b43f0 100644 --- a/system/t06_publish/PublishSourceUpdate1Test_gold +++ b/system/t06_publish/PublishSourceUpdate1Test_gold @@ -1 +1,3 @@ -Test +Updating component "main" with source "snap2" [snapshot]... + +You can run 'aptly publish update maverick .' to update the content of the published repository. diff --git a/system/t06_publish/PublishSourceUpdate2Test_gold b/system/t06_publish/PublishSourceUpdate2Test_gold index 345e6aef7..134f0d3f4 100644 --- a/system/t06_publish/PublishSourceUpdate2Test_gold +++ b/system/t06_publish/PublishSourceUpdate2Test_gold @@ -1 +1,4 @@ -Test +Updating component "main" with source "snap2" [snapshot]... +Updating component "test" with source "snap3" [snapshot]... + +You can run 'aptly publish update maverick .' to update the content of the published repository. diff --git a/system/t06_publish/PublishSourceUpdate3Test_gold b/system/t06_publish/PublishSourceUpdate3Test_gold index 345e6aef7..4d2fb4c8a 100644 --- a/system/t06_publish/PublishSourceUpdate3Test_gold +++ b/system/t06_publish/PublishSourceUpdate3Test_gold @@ -1 +1 @@ -Test +ERROR: unable to update: component "not-existent" does not exist diff --git a/system/t06_publish/PublishSwitch6Test_gold b/system/t06_publish/PublishSwitch6Test_gold index 9253c44d0..27a20838c 100644 --- a/system/t06_publish/PublishSwitch6Test_gold +++ b/system/t06_publish/PublishSwitch6Test_gold @@ -1 +1 @@ -ERROR: unable to switch: local repo with name snap1 not found +ERROR: unable to switch: not a published snapshot repository diff --git a/system/t06_publish/PublishUpdate15Test_gold b/system/t06_publish/PublishUpdate15Test_gold new file mode 100644 index 000000000..ebd8ad244 --- /dev/null +++ b/system/t06_publish/PublishUpdate15Test_gold @@ -0,0 +1,8 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: +Cleaning up prefix "." components ... + +Published snapshot repository ./maverick (origin: LP-PPA-gladky-anton-gnuplot) [i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {other-test: [snap3]: Created as empty}, {test: [snap2]: Created as empty} has been successfully updated. diff --git a/system/t06_publish/PublishUpdate16Test_gold b/system/t06_publish/PublishUpdate16Test_gold new file mode 100644 index 000000000..e989f2167 --- /dev/null +++ b/system/t06_publish/PublishUpdate16Test_gold @@ -0,0 +1,8 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: +Cleaning up prefix "." components ... + +Published snapshot repository ./maverick [i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick} has been successfully updated. diff --git a/system/t06_publish/PublishUpdate17Test_gold b/system/t06_publish/PublishUpdate17Test_gold new file mode 100644 index 000000000..9ad845772 --- /dev/null +++ b/system/t06_publish/PublishUpdate17Test_gold @@ -0,0 +1,8 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: +Cleaning up prefix "." components other-test, test... + +Published snapshot repository ./maverick [i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {other-test: [snap5]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {test: [snap4]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick} has been successfully updated. diff --git a/system/t06_publish/PublishUpdate18Test_gold b/system/t06_publish/PublishUpdate18Test_gold new file mode 100644 index 000000000..2e37b7026 --- /dev/null +++ b/system/t06_publish/PublishUpdate18Test_gold @@ -0,0 +1,8 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: +Cleaning up prefix "." components test... + +Published snapshot repository ./maverick [i386] publishes {other-test: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {test: [snap3]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick} has been successfully updated. diff --git a/system/t06_publish/PublishUpdate8Test_gold b/system/t06_publish/PublishUpdate8Test_gold index 09aa9845b..1a6ebd262 100644 --- a/system/t06_publish/PublishUpdate8Test_gold +++ b/system/t06_publish/PublishUpdate8Test_gold @@ -3,4 +3,4 @@ Generating metadata files and linking package files... Finalizing metadata files... Cleaning up prefix "." components contrib, main... -Publish for local repo ./squeeze [i386] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated. +Published local repository ./squeeze [i386] publishes {contrib: [repo2]}, {main: [repo1]} has been successfully updated. diff --git a/system/t06_publish/source.py b/system/t06_publish/source.py index 432f83a8f..9f352e20f 100644 --- a/system/t06_publish/source.py +++ b/system/t06_publish/source.py @@ -8,32 +8,13 @@ class PublishSourceAdd1Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror wheezy-contrib", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", - "aptly publish source add -component=contrib wheezy snap2" + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", ] - runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec" - + runCmd = "aptly publish source add -component=test maverick snap2" gold_processor = BaseTest.expand_environ - def check(self): - super(PublishSourceAdd1Test, self).check() - self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages') - self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.gz') - self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.bz2') - self.check_exists('public/dists/wheezy/contrib/Contents-i386.gz') - self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages') - self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.gz') - self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.bz2') - self.check_exists('public/dists/wheezy/contrib/Contents-amd64.gz') - - release = self.read_file('public/dists/wheezy/Release').split('\n') - components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None) - components = sorted(components.split(' ')) - if ['contrib', 'main'] != components: - raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'contrib main')) - class PublishSourceAdd2Test(BaseTest): """ @@ -42,42 +23,14 @@ class PublishSourceAdd2Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror wheezy-contrib", - "aptly snapshot create snap3 from mirror wheezy-non-free", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", - "aptly publish source add -component=contrib,non-free wheezy snap2 snap3" + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly snapshot create snap3 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", ] - runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec" - + runCmd = "aptly publish source add -component=test,other-test maverick snap2 snap3" gold_processor = BaseTest.expand_environ - def check(self): - super(PublishSourceAdd2Test, self).check() - self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages') - self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.gz') - self.check_exists('public/dists/wheezy/contrib/binary-i386/Packages.bz2') - self.check_exists('public/dists/wheezy/contrib/Contents-i386.gz') - self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages') - self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.gz') - self.check_exists('public/dists/wheezy/contrib/binary-amd64/Packages.bz2') - self.check_exists('public/dists/wheezy/contrib/Contents-amd64.gz') - - self.check_exists('public/dists/wheezy/non-free/binary-i386/Packages') - self.check_exists('public/dists/wheezy/non-free/binary-i386/Packages.gz') - self.check_exists('public/dists/wheezy/non-free/binary-i386/Packages.bz2') - self.check_exists('public/dists/wheezy/non-free/Contents-i386.gz') - self.check_exists('public/dists/wheezy/non-free/binary-amd64/Packages') - self.check_exists('public/dists/wheezy/non-free/binary-amd64/Packages.gz') - self.check_exists('public/dists/wheezy/non-free/binary-amd64/Packages.bz2') - self.check_exists('public/dists/wheezy/non-free/Contents-amd64.gz') - - release = self.read_file('public/dists/wheezy/Release').split('\n') - components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None) - components = sorted(components.split(' ')) - if ['contrib', 'main', 'non-free'] != components: - raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'contrib main non-free')) - class PublishSourceAdd3Test(BaseTest): """ @@ -86,11 +39,11 @@ class PublishSourceAdd3Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror gnuplot-maverick", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", ] - runCmd = "aptly publish add -component=main wheezy snap2" + runCmd = "aptly publish source add -component=main maverick snap2" expectedCode = 1 gold_processor = BaseTest.expand_environ @@ -102,12 +55,44 @@ class PublishSourceList1Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror wheezy-contrib", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", + "aptly publish source add -component=test maverick snap2", ] - runCmd = "aptly publish source list" + runCmd = "aptly publish source list maverick" + gold_processor = BaseTest.expand_environ + +class PublishSourceList2Test(BaseTest): + """ + publish source list: show source changes as JSON + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", + "aptly publish source add -component=test maverick snap2", + ] + runCmd = "aptly publish source list -json maverick" + gold_processor = BaseTest.expand_environ + + +class PublishSourceList3Test(BaseTest): + """ + publish source list: show source changes (empty) + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", + ] + runCmd = "aptly publish source list maverick" + expectedCode = 1 gold_processor = BaseTest.expand_environ @@ -118,12 +103,11 @@ class PublishSourceDrop1Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror wheezy-contrib", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", ] - runCmd = "aptly publish source drop" - + runCmd = "aptly publish source drop maverick" gold_processor = BaseTest.expand_environ @@ -134,12 +118,11 @@ class PublishSourceUpdate1Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror gnuplot-maverick", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", ] - runCmd = "aptly publish source update -component=main wheezy snap2" - + runCmd = "aptly publish source update -component=main maverick snap2" gold_processor = BaseTest.expand_environ @@ -150,13 +133,12 @@ class PublishSourceUpdate2Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror wheezy-main", - "aptly snapshot create snap3 from mirror gnuplot-maverick", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main,test snap1 snap2", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly snapshot create snap3 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main,test snap1 snap2", ] - runCmd = "aptly publish source update -component=main,test wheezy snap2 snap3" - + runCmd = "aptly publish source update -component=main,test maverick snap2 snap3" gold_processor = BaseTest.expand_environ @@ -167,11 +149,10 @@ class PublishSourceUpdate3Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", ] - runCmd = "aptly publish source update -component=not-existent wheezy snap1" - + runCmd = "aptly publish source update -component=not-existent maverick snap1" gold_processor = BaseTest.expand_environ @@ -182,12 +163,11 @@ class PublishSourceRemove1Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror wheezy-contrib", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main,contrib snap1 snap2", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main,test snap1 snap2", ] - runCmd = "aptly publish source remove -component=contrib wheezy" - + runCmd = "aptly publish source remove -component=test maverick" gold_processor = BaseTest.expand_environ @@ -198,13 +178,12 @@ class PublishSourceRemove2Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly snapshot create snap2 from mirror wheezy-contrib", - "aptly snapshot create snap3 from mirror wheezy-non-free", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main,contrib,non-free snap1 snap2 snap3", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly snapshot create snap3 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main,test,other-test snap1 snap2 snap3", ] - runCmd = "aptly publish source remove -component=contrib,non-free wheezy" - + runCmd = "aptly publish source remove -component=test,other-test maverick" gold_processor = BaseTest.expand_environ @@ -215,9 +194,9 @@ class PublishSourceRemove3Test(BaseTest): fixtureDB = True fixturePool = True fixtureCmds = [ - "aptly snapshot create snap1 from mirror wheezy-main", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=main snap1", + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=main snap1", ] - runCmd = "aptly publish source remove -component=not-existent wheezy" + runCmd = "aptly publish source remove -component=not-existent maverick" expectedCode = 1 gold_processor = BaseTest.expand_environ diff --git a/system/t06_publish/update.py b/system/t06_publish/update.py index 88114d926..3a24ec169 100644 --- a/system/t06_publish/update.py +++ b/system/t06_publish/update.py @@ -175,39 +175,6 @@ def check(self): self.check_exists('public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb') -#class PublishUpdate4Test(BaseTest): -# """ -# publish update: added some packages, but list of published archs doesn't change -# """ -# fixtureCmds = [ -# "aptly repo create local-repo", -# "aptly repo add local-repo ${files}/pyspi_0.6.1-1.3.dsc", -# "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick local-repo", -# "aptly repo add local-repo ${files}/libboost-program-options-dev_1.49.0.1_i386.deb" -# ] -# runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick" -# gold_processor = BaseTest.expand_environ -# -# def check(self): -# super(PublishUpdate4Test, self).check() -# -# self.check_exists('public/dists/maverick/InRelease') -# self.check_exists('public/dists/maverick/Release') -# self.check_exists('public/dists/maverick/Release.gpg') -# -# self.check_not_exists('public/dists/maverick/main/binary-i386/Packages') -# self.check_not_exists('public/dists/maverick/main/binary-i386/Packages.gz') -# self.check_not_exists('public/dists/maverick/main/binary-i386/Packages.bz2') -# self.check_exists('public/dists/maverick/main/source/Sources') -# self.check_exists('public/dists/maverick/main/source/Sources.gz') -# self.check_exists('public/dists/maverick/main/source/Sources.bz2') -# -# self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.dsc') -# self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.diff.gz') -# self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz') -# self.check_not_exists('public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb') - - class PublishUpdate5Test(BaseTest): """ publish update: no such publish @@ -216,20 +183,6 @@ class PublishUpdate5Test(BaseTest): expectedCode = 1 -class PublishUpdate6Test(BaseTest): - """ - publish update: not a local repo - """ - fixtureDB = True - fixturePool = True - fixtureCmds = [ - "aptly snapshot create snap1 from mirror gnuplot-maverick", - "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap1", - ] - runCmd = "aptly publish update maverick" - expectedCode = 1 - - class PublishUpdate7Test(BaseTest): """ publish update: multiple components, add some packages @@ -487,3 +440,169 @@ def check(self): self.check_exists('public/dists/bookworm/main/binary-i386/Packages.gz') self.check_exists('public/pool/bookworm/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb') + + +class PublishUpdate15Test(BaseTest): + """ + publish update: source added + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly snapshot create snap3 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main snap1", + "aptly publish source add -component=test,other-test maverick snap2 snap3" + ] + runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick" + + gold_processor = BaseTest.expand_environ + + def check(self): + super(PublishUpdate15Test, self).check() + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + + self.check_exists('public/dists/maverick/test/binary-i386/Packages') + self.check_exists('public/dists/maverick/test/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/test/binary-i386/Packages.bz2') + + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages') + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.bz2') + + release = self.read_file('public/dists/maverick/Release').split('\n') + components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None) + components = sorted(components.split(' ')) + if ['main', 'other-test', 'test'] != components: + raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'main other-test test')) + + +class PublishUpdate16Test(BaseTest): + """ + publish update: source removed + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly snapshot create snap3 empty", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main,test,other-test snap1 snap2 snap3", + "aptly publish source remove -component=test,other-test maverick" + ] + runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick" + + gold_processor = BaseTest.expand_environ + + def check(self): + super(PublishUpdate16Test, self).check() + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/main/Contents-i386.gz') + + release = self.read_file('public/dists/maverick/Release').split('\n') + components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None) + components = sorted(components.split(' ')) + if ['main'] != components: + raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'main')) + + +class PublishUpdate17Test(BaseTest): + """ + publish update: source updated + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly snapshot create snap3 empty", + "aptly snapshot create snap4 from mirror gnuplot-maverick", + "aptly snapshot create snap5 from mirror gnuplot-maverick", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main,test,other-test snap1 snap2 snap3", + "aptly publish source update -component=test,other-test maverick snap4 snap5" + ] + runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick" + + gold_processor = BaseTest.expand_environ + + def check(self): + super(PublishUpdate17Test, self).check() + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/main/Contents-i386.gz') + + self.check_exists('public/dists/maverick/test/binary-i386/Packages') + self.check_exists('public/dists/maverick/test/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/test/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/test/Contents-i386.gz') + + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages') + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/other-test/Contents-i386.gz') + + release = self.read_file('public/dists/maverick/Release').split('\n') + components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None) + components = sorted(components.split(' ')) + if ['main', 'other-test', 'test'] != components: + raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'main other-test test')) + + +class PublishUpdate18Test(BaseTest): + """ + publish update: source added, updated and removed + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap1 from mirror gnuplot-maverick", + "aptly snapshot create snap2 empty", + "aptly snapshot create snap3 from mirror gnuplot-maverick", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -architectures=i386 -component=main,test snap1 snap2", + "aptly publish source remove -component=main maverick", + "aptly publish source update -component=test maverick snap3", + "aptly publish source add -component=other-test maverick snap1" + ] + runCmd = "aptly publish update -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec maverick" + + gold_processor = BaseTest.expand_environ + + def check(self): + super(PublishUpdate18Test, self).check() + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/test/binary-i386/Packages') + self.check_exists('public/dists/maverick/test/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/test/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/test/Contents-i386.gz') + + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages') + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/other-test/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/other-test/Contents-i386.gz') + + release = self.read_file('public/dists/maverick/Release').split('\n') + components = next((e.split(': ')[1] for e in release if e.startswith('Components')), None) + components = sorted(components.split(' ')) + if ['other-test', 'test'] != components: + raise Exception("value of 'Components' in release file is '%s' and does not match '%s'." % (' '.join(components), 'other-test test')) diff --git a/system/t12_api/publish.py b/system/t12_api/publish.py index 325802d2d..8a0580efa 100644 --- a/system/t12_api/publish.py +++ b/system/t12_api/publish.py @@ -905,6 +905,58 @@ def check(self): self.check_exists("public/" + prefix + "/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc") +class PublishShowAPITestRepo(APITest): + """ + GET /publish/:prefix/:distribution + """ + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal( + self.upload("/api/files/" + d, + "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + self.check_equal(self.post_task("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "Architectures": ["i386", "source"], + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}], + "Signing": DefaultSigningOptions, + } + ).status_code, 201) + + repo_expected = { + 'AcquireByHash': False, + 'Architectures': ['i386', 'source'], + 'Codename': '', + 'Distribution': 'wheezy', + 'Label': '', + 'NotAutomatic': '', + 'ButAutomaticUpgrades': '', + 'Origin': '', + 'Path': prefix + '/' + 'wheezy', + 'Prefix': prefix, + 'SkipContents': False, + 'MultiDist': False, + 'SourceKind': 'local', + 'Sources': [{'Component': 'main', 'Name': repo1_name}], + 'Storage': '', + 'Suite': ''} + repo = self.get("/api/publish/" + prefix + "/wheezy") + self.check_equal(repo.status_code, 200) + self.check_equal(repo_expected, repo.json()) + + class ServePublishedListTestRepo(APITest): """ GET /repos @@ -1036,3 +1088,420 @@ def check(self): get = self.get("/repos/apiandserve/pool/main/b/boost-defaults/i-dont-exist") if get.status_code != 404: raise Exception(f"Expected status 404 != {get.status_code}") + + +class PublishSourcesAddAPITestRepo(APITest): + """ + POST /publish/:prefix/:distribution/sources + """ + fixtureGpg = True + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}], + "Signing": DefaultSigningOptions, + } + ).status_code, 201) + + repo2_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200) + + # Actual test + self.check_equal(self.post( + "/api/publish/" + prefix + "/wheezy/sources", + json={"Component": "test", "Name": repo2_name} + ).status_code, 201) + + sources_expected = [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}] + sources = self.get("/api/publish/" + prefix + "/wheezy/sources") + self.check_equal(sources.status_code, 200) + self.check_equal(sources_expected, sources.json()) + + +class PublishSourceUpdateAPITestRepo(APITest): + """ + PUT /publish/:prefix/:distribution/sources/main + """ + fixtureGpg = True + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}], + "Signing": DefaultSigningOptions, + } + ).status_code, 201) + + repo2_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200) + + # Actual test + self.check_equal(self.put( + "/api/publish/" + prefix + "/wheezy/sources/main", + json={"Component": "main", "Name": repo2_name} + ).status_code, 200) + + sources_expected = [{"Component": "main", "Name": repo2_name}] + sources = self.get("/api/publish/" + prefix + "/wheezy/sources") + self.check_equal(sources.status_code, 200) + self.check_equal(sources_expected, sources.json()) + + +class PublishSourcesUpdateAPITestRepo(APITest): + """ + PUT /publish/:prefix/:distribution/sources + """ + fixtureGpg = True + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + repo2_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}], + "Signing": DefaultSigningOptions, + } + ).status_code, 201) + + # Actual test + self.check_equal(self.put( + "/api/publish/" + prefix + "/wheezy/sources", + json=[{"Component": "test", "Name": repo1_name}, {"Component": "other-test", "Name": repo2_name}] + ).status_code, 200) + + sources_expected = [{"Component": "other-test", "Name": repo2_name}, {"Component": "test", "Name": repo1_name}] + sources = self.get("/api/publish/" + prefix + "/wheezy/sources") + self.check_equal(sources.status_code, 200) + self.check_equal(sources_expected, sources.json()) + + +class PublishSourceRemoveAPITestRepo(APITest): + """ + DELETE /publish/:prefix/:distribution/sources/test + """ + fixtureGpg = True + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + repo2_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}], + "Signing": DefaultSigningOptions, + } + ).status_code, 201) + + # Actual test + self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/test").status_code, 200) + + sources_expected = [{"Component": "main", "Name": repo1_name}] + sources = self.get("/api/publish/" + prefix + "/wheezy/sources") + self.check_equal(sources.status_code, 200) + self.check_equal(sources_expected, sources.json()) + + +class PublishSourcesDropAPITestRepo(APITest): + """ + DELETE /publish/:prefix/:distribution/sources + """ + fixtureGpg = True + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + repo2_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}], + "Signing": DefaultSigningOptions, + } + ).status_code, 201) + + self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/test").status_code, 200) + + # Actual test + self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources").status_code, 200) + + self.check_equal(self.get("/api/publish/" + prefix + "/wheezy/sources").status_code, 404) + + +class PublishSourcesListAPITestRepo(APITest): + """ + GET /publish/:prefix/:distribution/sources + """ + fixtureGpg = True + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + repo2_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}], + "Signing": DefaultSigningOptions, + } + ).status_code, 201) + + # Actual test + self.check_equal(self.post( + "/api/publish/" + prefix + "/wheezy/sources", + json={"Component": "test", "Name": repo1_name} + ).status_code, 201) + + self.check_equal(self.put( + "/api/publish/" + prefix + "/wheezy/sources/main", + json={"Component": "main", "Name": repo2_name} + ).status_code, 200) + + self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/main").status_code, 200) + + sources_expected = [{"Component": "test", "Name": repo1_name}] + sources = self.get("/api/publish/" + prefix + "/wheezy/sources") + self.check_equal(sources.status_code, 200) + self.check_equal(sources_expected, sources.json()) + + +class PublishUpdateSourcesAPITestRepo(APITest): + """ + POST /publish/:prefix/:distribution/update + """ + fixtureGpg = True + + def check(self): + repo1_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo1_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo1_name + "/file/" + d).status_code, 200) + + repo2_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo2_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo2_name + "/file/" + d).status_code, 200) + + repo3_name = self.random_name() + self.check_equal(self.post( + "/api/repos", json={"Name": repo3_name, "DefaultDistribution": "wheezy"}).status_code, 201) + + d = self.random_name() + self.check_equal(self.upload("/api/files/" + d, + "libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200) + + self.check_equal(self.post("/api/repos/" + repo3_name + "/file/" + d).status_code, 200) + + # publishing under prefix, default distribution + prefix = self.random_name() + self.check_equal(self.post( + "/api/publish/" + prefix, + json={ + "Signing": DefaultSigningOptions, + "SourceKind": "local", + "Sources": [{"Component": "main", "Name": repo1_name}, {"Component": "test", "Name": repo2_name}], + } + ).status_code, 201) + + # delete 'main' component + self.check_equal(self.delete("/api/publish/" + prefix + "/wheezy/sources/main").status_code, 200) + + # update 'test' component + self.check_equal(self.put( + "/api/publish/" + prefix + "/wheezy/sources/test", + json={"Component": "test", "Name": repo1_name} + ).status_code, 200) + + # add 'other-test' component + self.check_equal(self.post( + "/api/publish/" + prefix + "/wheezy/sources", + json={"Component": "other-test", "Name": repo3_name} + ).status_code, 201) + + sources_expected = [{"Component": "other-test", "Name": repo3_name}, {"Component": "test", "Name": repo1_name}] + sources = self.get("/api/publish/" + prefix + "/wheezy/sources") + self.check_equal(sources.status_code, 200) + self.check_equal(sources_expected, sources.json()) + + # update published repository and publish new content + self.check_equal(self.post( + "/api/publish/" + prefix + "/wheezy/update", + json={ + "AcquireByHash": True, + "MultiDist": False, + "Signing": DefaultSigningOptions, + "SkipBz2": True, + "SkipContents": True, + } + ).status_code, 200) + + repo_expected = { + 'AcquireByHash': True, + 'Architectures': ['i386', 'source'], + 'Codename': '', + 'Distribution': 'wheezy', + 'Label': '', + 'Origin': '', + 'NotAutomatic': '', + 'ButAutomaticUpgrades': '', + 'Path': prefix + '/' + 'wheezy', + 'Prefix': prefix, + 'SkipContents': True, + 'MultiDist': False, + 'SourceKind': 'local', + 'Sources': [{"Component": "other-test", "Name": repo3_name}, {"Component": "test", "Name": repo1_name}], + 'Storage': '', + 'Suite': ''} + + all_repos = self.get("/api/publish") + self.check_equal(all_repos.status_code, 200) + self.check_in(repo_expected, all_repos.json())