Skip to content

Commit

Permalink
update to remote-sdk-go 0.1.0 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Schrock authored and Derek Smart committed Jan 10, 2020
1 parent 8a4d33a commit 641513a
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 32 deletions.
23 changes: 23 additions & 0 deletions .github/get-binary-name
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

BASENAME=$1
RUNNEROS=$2

echo -n ::set-output name=binary_name::
case $RUNNEROS in
Linux)
echo ${BASENAME}-linux
;;

macOS)
echo ${BASENAME}-darwin
;;

Windows)
echo ${BASENAME}-windows
;;

*)
echo $BASENAME
;;
esac
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ jobs:
go-version: '1.13.5'
- name: Build
run: go build -v ./...
- name: Build command
run: go build -o build/ssh ./cmd/ssh
- name: Test
run: go test -v ./...
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright The Titan Project Contributors.
#

#
# When a tag is pushed, build and upload the binary to the in-progress draft release.
#
name: Release

on: create

jobs:
upload:
name: Build and Upload
strategy:
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with:
go-version: '1.13.5'
- name: Get Draft Release
id: draft_release
run: |
echo -n ::set-output name=upload_url::
curl -sH "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq -rc '.[] | select(.draft) | .upload_url'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Binary Name
id: binary_name
run: ./.github/get-binary-name ssh ${{ runner.os }}
- name: Build
run: go build -o build/ssh ./cmd/ssh
- name: Test
run: go test ./...
- name: Upload Artifact
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.draft_release.outputs.upload_url }}
asset_path: ./build/ssh
asset_name: ${{ steps.binary_name.outputs.binary_name }}
asset_content_type: application/octet-stream
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

# IDE files
/.idea

# Build artifacts
/build
7 changes: 7 additions & 0 deletions cmd/ssh/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/titan-data/remote-sdk-go/remote"

func main() {
remote.Serve("ssh")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/titan-data/ssh-remote-go

require (
github.com/stretchr/testify v1.4.0
github.com/titan-data/remote-sdk-go v0.0.3
github.com/titan-data/remote-sdk-go v0.1.0
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876
)

Expand Down
75 changes: 75 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,22 +1,97 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI=
github.com/hashicorp/go-hclog v0.10.1 h1:uyt/l0dWjJ879yiAu+T7FG3/6QX+zwm4bQ8P7XsYt3o=
github.com/hashicorp/go-hclog v0.10.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-plugin v1.0.1 h1:4OtAfUGbnKC6yS48p0CtMX2oFYtzFZVv6rok3cRWgnE=
github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/titan-data/remote-sdk-go v0.0.2 h1:NEta4CwcUPj7PGbbxvpxIXem7t0EIbXBKegJsy1hafE=
github.com/titan-data/remote-sdk-go v0.0.2/go.mod h1:b4McaOFiLYWv2/wCQW/sE2BcCSNz/Ae6iKKEtqw703w=
github.com/titan-data/remote-sdk-go v0.0.3 h1:kGLc7JP7znTcXyl3gRML2jEST99ebdhz0Cn+nVdL6SQ=
github.com/titan-data/remote-sdk-go v0.0.3/go.mod h1:b4McaOFiLYWv2/wCQW/sE2BcCSNz/Ae6iKKEtqw703w=
github.com/titan-data/remote-sdk-go v0.1.0 h1:Xab4sduqyGdo04eJ5mQ2lIfAYZDjHJ4AzlK4oJ5EqqE=
github.com/titan-data/remote-sdk-go v0.1.0/go.mod h1:u7w3Olu3EtjoFcHzxUOzelxedey4q2nveuKLvgRO7tg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
11 changes: 8 additions & 3 deletions ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ import (
type sshRemote struct {
}

func (s sshRemote) Type() string {
return "ssh"
func (s sshRemote) Type() (string, error) {
return "ssh", nil
}

func (s sshRemote) FromURL(url *url.URL, additionalProperties map[string]string) (map[string]interface{}, error) {
func (s sshRemote) FromURL(rawUrl string, additionalProperties map[string]string) (map[string]interface{}, error) {
url, err := url.Parse(rawUrl)
if err != nil {
return nil, err
}

if url.Scheme != "ssh" {
return nil, errors.New("invalid remote scheme")
}
Expand Down
43 changes: 15 additions & 28 deletions ssh/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ import (
"github.com/titan-data/remote-sdk-go/remote"
"golang.org/x/crypto/ssh/terminal"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"testing"
)

func TestRegistered(t *testing.T) {
r := remote.Get("ssh")
assert.Equal(t, "ssh", r.Type())
ret, _ := r.Type()
assert.Equal(t, "ssh", ret)
}

func TestFromURL(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user:pass@host:8022/path")
props, _ := r.FromURL(u, map[string]string{})
props, _ := r.FromURL("ssh://user:pass@host:8022/path", map[string]string{})
assert.Equal(t, "user", props["username"])
assert.Equal(t, "pass", props["password"])
assert.Equal(t, "host", props["address"])
Expand All @@ -35,8 +34,7 @@ func TestFromURL(t *testing.T) {

func TestSimple(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user@host/path")
props, _ := r.FromURL(u, map[string]string{})
props, _ := r.FromURL("ssh://user@host/path", map[string]string{})
assert.Equal(t, "user", props["username"])
assert.Nil(t, props["password"])
assert.Equal(t, "host", props["address"])
Expand All @@ -47,78 +45,67 @@ func TestSimple(t *testing.T) {

func TestKeyFile(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user@host/path")
props, _ := r.FromURL(u, map[string]string{"keyFile": "~/.ssh/id_dsa"})
props, _ := r.FromURL("ssh://user@host/path", map[string]string{"keyFile": "~/.ssh/id_dsa"})
assert.Equal(t, "~/.ssh/id_dsa", props["keyFile"])
}

func TestRelativePath(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user@host/~/relative/path")
props, _ := r.FromURL(u, map[string]string{})
props, _ := r.FromURL("ssh://user@host/~/relative/path", map[string]string{})
assert.Equal(t, "relative/path", props["path"])
}

func TestBadScheme(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("foo://user:pass@host:8022/path")
_, err := r.FromURL(u, map[string]string{})
_, err := r.FromURL("foo://user:pass@host:8022/path", map[string]string{})
assert.NotNil(t, err)
}

func TestBadPasswordAndKeyFile(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user:password@host/path")
_, err := r.FromURL(u, map[string]string{"keyFile": "~/.ssh/id_dsa"})
_, err := r.FromURL("ssh://user:password@host/path", map[string]string{"keyFile": "~/.ssh/id_dsa"})
assert.NotNil(t, err)
}

func TestBadProperty(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user@host/path")
_, err := r.FromURL(u, map[string]string{"foo": "bar"})
_, err := r.FromURL("ssh://user@host/path", map[string]string{"foo": "bar"})
assert.NotNil(t, err)
}

func TestBadMissingHost(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh:///path")
_, err := r.FromURL(u, map[string]string{})
_, err := r.FromURL("ssh:///path", map[string]string{})
assert.NotNil(t, err)
}

func TestBadSchemeOnly(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh")
_, err := r.FromURL(u, map[string]string{})
_, err := r.FromURL("ssh", map[string]string{})
assert.NotNil(t, err)
}

func TestBadMissingUsername(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://host/path")
_, err := r.FromURL(u, map[string]string{})
_, err := r.FromURL("ssh://host/path", map[string]string{})
assert.NotNil(t, err)
}

func TestBadPort(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user@host:29348529384572398457932847539/path")
_, err := r.FromURL(u, map[string]string{})
_, err := r.FromURL("ssh://user@host:29348529384572398457932847539/path", map[string]string{})
assert.NotNil(t, err)
}

func TestBadMissingPath(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user@host")
_, err := r.FromURL(u, map[string]string{})
_, err := r.FromURL("ssh://user@host", map[string]string{})
assert.NotNil(t, err)
}

func TestBadMissingHostWithUser(t *testing.T) {
r := remote.Get("ssh")
u, _ := url.Parse("ssh://user@/path")
_, err := r.FromURL(u, map[string]string{})
_, err := r.FromURL("ssh://user@/path", map[string]string{})
assert.NotNil(t, err)
}

Expand Down

0 comments on commit 641513a

Please sign in to comment.