Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/embedded_files_test/exec_script/metadata.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: exec_script
author: hulto
description: Copies a script and executes it.
tactic: UNSPECIFIED
1 change: 1 addition & 0 deletions bin/embedded_files_test/print/metadata.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: print
author: hulto
description: It just prints.
tactic: UNSPECIFIED
2 changes: 1 addition & 1 deletion tavern/internal/ent/schema/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func HookCreateRepoPrivateKey() ent.Hook {
}

// Prepend https schema if no schema specified
if u, ok := mut.URL(); ok && (!strings.HasPrefix(u, "http://") && !strings.HasPrefix(u, "ssh://")) {
if u, ok := mut.URL(); ok && (!strings.HasPrefix(u, "https://") && !strings.HasPrefix(u, "http://") && !strings.HasPrefix(u, "ssh://")) {
mut.SetURL(fmt.Sprintf("https://%s", u))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
state: |
INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin)
VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,true);
requestor:
session_token: secretToken
query: |
mutation CreateRepository($input: CreateRepositoryInput!) {
createRepository(input: $input) {
url

owner {
id
}
}
}
variables:
input:
url: "https://github.com/spellshift/realm"

expected:
createRepository:
url: "https://github.com/spellshift/realm"
owner:
id: "5"
7 changes: 4 additions & 3 deletions tavern/tomes/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/filemode"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/transport"
gitssh "github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/go-git/go-git/v5/storage/memory"
"golang.org/x/crypto/ssh"
Expand Down Expand Up @@ -53,20 +54,20 @@ type GitImporter struct {
// result should be included.
func (importer *GitImporter) Import(ctx context.Context, entRepo *ent.Repository, filters ...func(path string) bool) error {
// Use Private Key Auth for SSH
var authMethod *gitssh.PublicKeys
var authMethod transport.AuthMethod
if strings.HasPrefix(entRepo.URL, "ssh://") {
privKey, err := ssh.ParsePrivateKey([]byte(entRepo.PrivateKey))
if err != nil {
return fmt.Errorf("failed to parse private key for repository: %w", err)
}
authMethod = &gitssh.PublicKeys{
authMethod = transport.AuthMethod(&gitssh.PublicKeys{
User: "git",
Signer: privKey,
HostKeyCallbackHelper: gitssh.HostKeyCallbackHelper{
// Ignore Host Keys
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
},
}
})
}

// Clone Repository (In-Memory)
Expand Down
3 changes: 3 additions & 0 deletions tavern/tomes/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func (meta MetadataDefinition) Validate() error {
if meta.Description == "" {
return fmt.Errorf("must set 'description'")
}
if meta.Tactic == "" {
return fmt.Errorf("must set 'tactic'")
}
for _, paramDef := range meta.ParamDefs {
if err := paramDef.Validate(); err != nil {
return fmt.Errorf("invalid parameter definition (%q): %w", meta.Name, err)
Expand Down