@@ -7,22 +7,22 @@ import (
77 "os"
88 "path"
99
10+ "code.cloudfoundry.org/goshims/filepathshim/filepath_fake"
11+ "code.cloudfoundry.org/goshims/osshim/os_fake"
1012 "code.cloudfoundry.org/lager"
1113 "code.cloudfoundry.org/lager/lagertest"
1214 "code.cloudfoundry.org/localdriver"
1315 "code.cloudfoundry.org/voldriver"
16+ "code.cloudfoundry.org/voldriver/driverhttp"
1417 . "github.com/onsi/ginkgo"
1518 . "github.com/onsi/gomega"
16- "code.cloudfoundry.org/voldriver/driverhttp"
17- "code.cloudfoundry.org/goshims/osshim/os_fake"
18- "code.cloudfoundry.org/goshims/filepathshim/filepath_fake"
1919)
2020
2121var _ = Describe ("Local Driver" , func () {
2222 var (
2323 testLogger lager.Logger
2424 ctx context.Context
25- env voldriver.Env
25+ env voldriver.Env
2626 fakeOs * os_fake.FakeOs
2727 fakeFilepath * filepath_fake.FakeFilepath
2828 localDriver * localdriver.LocalDriver
@@ -54,8 +54,8 @@ var _ = Describe("Local Driver", func() {
5454
5555 Context ("when the volume has been created" , func () {
5656 BeforeEach (func () {
57- createSuccessful (env , localDriver , fakeOs , volumeId , "" )
58- mountSuccessful (env , localDriver , volumeId , fakeFilepath , "" )
57+ createSuccessful (env , localDriver , fakeOs , volumeId )
58+ mountSuccessful (env , localDriver , volumeId , fakeFilepath )
5959 })
6060
6161 AfterEach (func () {
@@ -99,71 +99,6 @@ var _ = Describe("Local Driver", func() {
9999 })
100100 })
101101
102- Context ("when the volume has been created with a passcode" , func () {
103- const passcode = "aPassc0de"
104-
105- BeforeEach (func () {
106- createSuccessful (env , localDriver , fakeOs , volumeId , passcode )
107- })
108-
109- AfterEach (func () {
110- removeSuccessful (env , localDriver , volumeId )
111- })
112-
113- Context ("when mounting with the right passcode" , func () {
114- BeforeEach (func () {
115- mountSuccessful (env , localDriver , volumeId , fakeFilepath , passcode )
116- })
117- AfterEach (func () {
118- unmountSuccessful (env , localDriver , volumeId )
119- })
120-
121- It ("should mount the volume on the local filesystem" , func () {
122- Expect (fakeFilepath .AbsCallCount ()).To (Equal (3 ))
123- Expect (fakeOs .MkdirAllCallCount ()).To (Equal (4 ))
124- Expect (fakeOs .SymlinkCallCount ()).To (Equal (1 ))
125- from , to := fakeOs .SymlinkArgsForCall (0 )
126- Expect (from ).To (Equal ("/path/to/mount/_volumes/test-volume-id" ))
127- Expect (to ).To (Equal ("/path/to/mount/_mounts/test-volume-id" ))
128- })
129-
130- It ("returns the mount point on a /VolumeDriver.Get response" , func () {
131- getResponse := getSuccessful (env , localDriver , volumeId )
132- Expect (getResponse .Volume .Mountpoint ).To (Equal ("/path/to/mount/_mounts/test-volume-id" ))
133- })
134- })
135-
136- Context ("when mounting with the wrong passcode" , func () {
137- It ("returns an error" , func () {
138- mountResponse := localDriver .Mount (env , voldriver.MountRequest {
139- Name : volumeId ,
140- Opts : map [string ]interface {}{"passcode" : "wrong" },
141- })
142- Expect (mountResponse .Err ).To (Equal ("Volume " + volumeId + " access denied" ))
143- })
144- })
145-
146- Context ("when mounting with the wrong passcode type" , func () {
147- It ("returns an error" , func () {
148- mountResponse := localDriver .Mount (env , voldriver.MountRequest {
149- Name : volumeId ,
150- Opts : map [string ]interface {}{"passcode" : nil },
151- })
152- Expect (mountResponse .Err ).To (Equal ("Opts.passcode must be a string value" ))
153- })
154- })
155-
156- Context ("when mounting with no passcode" , func () {
157- It ("returns an error" , func () {
158- mountResponse := localDriver .Mount (env , voldriver.MountRequest {
159- Name : volumeId ,
160- })
161- Expect (mountResponse .Err ).To (Equal ("Volume " + volumeId + " requires a passcode" ))
162- })
163- })
164-
165- })
166-
167102 Context ("when the volume has not been created" , func () {
168103 It ("returns an error" , func () {
169104 mountResponse := localDriver .Mount (env , voldriver.MountRequest {
@@ -177,12 +112,12 @@ var _ = Describe("Local Driver", func() {
177112 Describe ("Unmount" , func () {
178113 Context ("when a volume has been created" , func () {
179114 BeforeEach (func () {
180- createSuccessful (env , localDriver , fakeOs , volumeId , "" )
115+ createSuccessful (env , localDriver , fakeOs , volumeId )
181116 })
182117
183118 Context ("when a volume has been mounted" , func () {
184119 BeforeEach (func () {
185- mountSuccessful (env , localDriver , volumeId , fakeFilepath , "" )
120+ mountSuccessful (env , localDriver , volumeId , fakeFilepath )
186121 })
187122
188123 It ("After unmounting /VolumeDriver.Get returns no mountpoint" , func () {
@@ -200,7 +135,7 @@ var _ = Describe("Local Driver", func() {
200135
201136 Context ("when the same volume is mounted a second time then unmounted" , func () {
202137 BeforeEach (func () {
203- mountSuccessful (env , localDriver , volumeId , fakeFilepath , "" )
138+ mountSuccessful (env , localDriver , volumeId , fakeFilepath )
204139 unmountSuccessful (env , localDriver , volumeId )
205140 })
206141
@@ -277,27 +212,14 @@ var _ = Describe("Local Driver", func() {
277212 })
278213
279214 Describe ("Create" , func () {
280- Context ("when a passcode is wrong type" , func () {
281- It ("returns an error" , func () {
282- createResponse := localDriver .Create (env , voldriver.CreateRequest {
283- Name : "volume" ,
284- Opts : map [string ]interface {}{
285- "passcode" : nil ,
286- },
287- })
288-
289- Expect (createResponse .Err ).To (Equal ("Opts.passcode must be a string value" ))
290- })
291- })
292-
293215 Context ("when a second create is called with the same volume ID" , func () {
294216 BeforeEach (func () {
295- createSuccessful (env , localDriver , fakeOs , "volume" , "" )
217+ createSuccessful (env , localDriver , fakeOs , "volume" )
296218 })
297219
298220 Context ("with the same opts" , func () {
299221 It ("does nothing" , func () {
300- createSuccessful (env , localDriver , fakeOs , "volume" , "" )
222+ createSuccessful (env , localDriver , fakeOs , "volume" )
301223 })
302224 })
303225 })
@@ -306,7 +228,7 @@ var _ = Describe("Local Driver", func() {
306228 Describe ("Get" , func () {
307229 Context ("when the volume has been created" , func () {
308230 It ("returns the volume name" , func () {
309- createSuccessful (env , localDriver , fakeOs , volumeId , "" )
231+ createSuccessful (env , localDriver , fakeOs , volumeId )
310232 getSuccessful (env , localDriver , volumeId )
311233 })
312234 })
@@ -321,8 +243,8 @@ var _ = Describe("Local Driver", func() {
321243 Describe ("Path" , func () {
322244 Context ("when a volume is mounted" , func () {
323245 BeforeEach (func () {
324- createSuccessful (env , localDriver , fakeOs , volumeId , "" )
325- mountSuccessful (env , localDriver , volumeId , fakeFilepath , "" )
246+ createSuccessful (env , localDriver , fakeOs , volumeId )
247+ mountSuccessful (env , localDriver , volumeId , fakeFilepath )
326248 })
327249
328250 It ("returns the mount point on a /VolumeDriver.Path" , func () {
@@ -350,7 +272,7 @@ var _ = Describe("Local Driver", func() {
350272 )
351273 BeforeEach (func () {
352274 volumeName = "my-volume"
353- createSuccessful (env , localDriver , fakeOs , volumeName , "" )
275+ createSuccessful (env , localDriver , fakeOs , volumeName )
354276 })
355277
356278 It ("returns an error on /VolumeDriver.Path" , func () {
@@ -366,7 +288,7 @@ var _ = Describe("Local Driver", func() {
366288 Describe ("List" , func () {
367289 Context ("when there are volumes" , func () {
368290 BeforeEach (func () {
369- createSuccessful (env , localDriver , fakeOs , volumeId , "" )
291+ createSuccessful (env , localDriver , fakeOs , volumeId )
370292 })
371293
372294 It ("returns the list of volumes" , func () {
@@ -403,7 +325,7 @@ var _ = Describe("Local Driver", func() {
403325
404326 Context ("when the volume has been created" , func () {
405327 BeforeEach (func () {
406- createSuccessful (env , localDriver , fakeOs , volumeId , "" )
328+ createSuccessful (env , localDriver , fakeOs , volumeId )
407329 })
408330
409331 It ("/VolumePlugin.Remove destroys volume" , func () {
@@ -418,7 +340,7 @@ var _ = Describe("Local Driver", func() {
418340
419341 Context ("when volume has been mounted" , func () {
420342 It ("/VolumePlugin.Remove unmounts and destroys volume" , func () {
421- mountSuccessful (env , localDriver , volumeId , fakeFilepath , "" )
343+ mountSuccessful (env , localDriver , volumeId , fakeFilepath )
422344
423345 removeResponse := localDriver .Remove (env , voldriver.RemoveRequest {
424346 Name : volumeId ,
@@ -462,14 +384,9 @@ func getSuccessful(env voldriver.Env, localDriver voldriver.Driver, volumeName s
462384 return getResponse
463385}
464386
465- func createSuccessful (env voldriver.Env , localDriver voldriver.Driver , fakeOs * os_fake.FakeOs , volumeName string , passcode string ) {
466- opts := map [string ]interface {}{}
467- if passcode != "" {
468- opts ["passcode" ] = passcode
469- }
387+ func createSuccessful (env voldriver.Env , localDriver voldriver.Driver , fakeOs * os_fake.FakeOs , volumeName string ) {
470388 createResponse := localDriver .Create (env , voldriver.CreateRequest {
471389 Name : volumeName ,
472- Opts : opts ,
473390 })
474391 Expect (createResponse .Err ).To (Equal ("" ))
475392
@@ -480,15 +397,10 @@ func createSuccessful(env voldriver.Env, localDriver voldriver.Driver, fakeOs *o
480397 Expect (fileMode ).To (Equal (os .ModePerm ))
481398}
482399
483- func mountSuccessful (env voldriver.Env , localDriver voldriver.Driver , volumeName string , fakeFilepath * filepath_fake.FakeFilepath , passcode string ) {
400+ func mountSuccessful (env voldriver.Env , localDriver voldriver.Driver , volumeName string , fakeFilepath * filepath_fake.FakeFilepath ) {
484401 fakeFilepath .AbsReturns ("/path/to/mount/" , nil )
485- opts := map [string ]interface {}{}
486- if passcode != "" {
487- opts ["passcode" ] = passcode
488- }
489402 mountResponse := localDriver .Mount (env , voldriver.MountRequest {
490403 Name : volumeName ,
491- Opts : opts ,
492404 })
493405 Expect (mountResponse .Err ).To (Equal ("" ))
494406 Expect (mountResponse .Mountpoint ).To (Equal ("/path/to/mount/_mounts/" + volumeName ))
0 commit comments