cmd/uplink: fix importing access in Windows
Currently os.Create was leaving a file open causing atomic write file to fail with access denied. Also add a specific test for importing an access. Change-Id: Id188bc480e795849ec7fdc72b1fc86433d76c47a
This commit is contained in:
parent
6a805b2891
commit
75ca01e381
@ -7,12 +7,14 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/cmd/uplink/cmd"
|
||||
"storj.io/uplink"
|
||||
)
|
||||
@ -54,3 +56,16 @@ func TestRegisterAccessTimeout(t *testing.T) {
|
||||
assert.Equal(t, "", endpoint)
|
||||
close(ch)
|
||||
}
|
||||
|
||||
func TestAccessImport(t *testing.T) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
const testAccess = "12edqwjdy4fmoHasYrxLzmu8Ubv8Hsateq1LPYne6Jzd64qCsYgET53eJzhB4L2pWDKBpqMowxt8vqLCbYxu8Qz7BJVH1CvvptRt9omm24k5GAq1R99mgGjtmc6yFLqdEFgdevuQwH5yzXCEEtbuBYYgES8Stb1TnuSiU3sa62bd2G88RRgbTCtwYrB8HZ7CLjYWiWUphw7RNa3NfD1TW6aUJ6E5D1F9AM6sP58X3D4H7tokohs2rqCkwRT"
|
||||
|
||||
uplinkExe := ctx.Compile("storj.io/storj/cmd/uplink")
|
||||
|
||||
output, err := exec.Command(uplinkExe, "--config-dir", ctx.Dir("uplink"), "import", testAccess).CombinedOutput()
|
||||
t.Log(string(output))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
@ -207,11 +207,12 @@ func createConfigFile(path string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = os.Create(path)
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
func fileExists(path string) (bool, error) {
|
||||
|
2
go.mod
2
go.mod
@ -48,7 +48,7 @@ require (
|
||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
|
||||
google.golang.org/api v0.20.0 // indirect
|
||||
gopkg.in/segmentio/analytics-go.v3 v3.1.0
|
||||
storj.io/common v0.0.0-20210412024514-5bcb1fff421e
|
||||
storj.io/common v0.0.0-20210419115916-eabb53ea1332
|
||||
storj.io/drpc v0.0.20
|
||||
storj.io/monkit-jaeger v0.0.0-20210225162224-66fb37637bf6
|
||||
storj.io/private v0.0.0-20210403210935-5fd57695864c
|
||||
|
4
go.sum
4
go.sum
@ -941,8 +941,8 @@ sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3
|
||||
storj.io/common v0.0.0-20200424175742-65ac59022f4f/go.mod h1:pZyXiIE7bGETIRXtfs0nICqMwp7PM8HqnDuyUeldNA0=
|
||||
storj.io/common v0.0.0-20201026135900-1aaeec90670b/go.mod h1:GqdmNf3fLm2UZX/7Zr0BLFCJ4gFjgm6eHrk/fnmr5jQ=
|
||||
storj.io/common v0.0.0-20210406151410-a1147267017f/go.mod h1:Udjm4roy/lhL7PHDWlNVhuVxlohcPiyHMeuigw94SDE=
|
||||
storj.io/common v0.0.0-20210412024514-5bcb1fff421e h1:/kXB89KYCVxgY37YjQXvCfNUpSTMDaJfCYeDnT4ar9A=
|
||||
storj.io/common v0.0.0-20210412024514-5bcb1fff421e/go.mod h1:Udjm4roy/lhL7PHDWlNVhuVxlohcPiyHMeuigw94SDE=
|
||||
storj.io/common v0.0.0-20210419115916-eabb53ea1332 h1:A5AGxOdbi/9JpqWmvaqsnqxxeE5sUCiCn67JBUHPmc4=
|
||||
storj.io/common v0.0.0-20210419115916-eabb53ea1332/go.mod h1:Udjm4roy/lhL7PHDWlNVhuVxlohcPiyHMeuigw94SDE=
|
||||
storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw=
|
||||
storj.io/drpc v0.0.14/go.mod h1:82nfl+6YwRwF6UG31cEWWUqv/FaKvP5SGqUvoqTxCMA=
|
||||
storj.io/drpc v0.0.20 h1:nzOxsetLi0fJ8xCL92LPlYL0B6iYdDDk1Cpdbn0/r9Y=
|
||||
|
Loading…
Reference in New Issue
Block a user