From 641513a89410782dee5b50d6f1d3dcd8a3066723 Mon Sep 17 00:00:00 2001 From: Eric Schrock Date: Fri, 10 Jan 2020 10:52:22 -0500 Subject: [PATCH] update to remote-sdk-go 0.1.0 (#3) --- .github/get-binary-name | 23 +++++++++ .github/workflows/pull-request.yml | 2 + .github/workflows/release.yml | 47 +++++++++++++++++++ .gitignore | 3 ++ cmd/ssh/main.go | 7 +++ go.mod | 2 +- go.sum | 75 ++++++++++++++++++++++++++++++ ssh/ssh.go | 11 +++-- ssh/ssh_test.go | 43 ++++++----------- 9 files changed, 181 insertions(+), 32 deletions(-) create mode 100755 .github/get-binary-name create mode 100644 .github/workflows/release.yml create mode 100644 cmd/ssh/main.go diff --git a/.github/get-binary-name b/.github/get-binary-name new file mode 100755 index 0000000..06861e0 --- /dev/null +++ b/.github/get-binary-name @@ -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 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7554119..a1e94c0 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -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 ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..372a09b --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.gitignore b/.gitignore index 2e49d54..c832d6d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ # IDE files /.idea + +# Build artifacts +/build diff --git a/cmd/ssh/main.go b/cmd/ssh/main.go new file mode 100644 index 0000000..b73a108 --- /dev/null +++ b/cmd/ssh/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/titan-data/remote-sdk-go/remote" + +func main() { + remote.Serve("ssh") +} diff --git a/go.mod b/go.mod index 70beae3..12c1cc2 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 88ff617..3171489 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/ssh/ssh.go b/ssh/ssh.go index 6bc316d..d87061d 100644 --- a/ssh/ssh.go +++ b/ssh/ssh.go @@ -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") } diff --git a/ssh/ssh_test.go b/ssh/ssh_test.go index 785c68f..d0774f4 100644 --- a/ssh/ssh_test.go +++ b/ssh/ssh_test.go @@ -10,7 +10,6 @@ import ( "github.com/titan-data/remote-sdk-go/remote" "golang.org/x/crypto/ssh/terminal" "io/ioutil" - "net/url" "os" "path/filepath" "testing" @@ -18,13 +17,13 @@ import ( 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"]) @@ -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"]) @@ -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) }