@@ -4,6 +4,7 @@ import org.mockito.Mockito.when
4
4
import org .scalatest .flatspec .AnyFlatSpec
5
5
import org .scalatest .matchers .should .Matchers
6
6
7
+ import java .util .UUID
7
8
import scala .util .{Failure , Try }
8
9
9
10
object BlobPathBuilderSpec {
@@ -57,12 +58,59 @@ class BlobPathBuilderSpec extends AnyFlatSpec with Matchers with MockSugar {
57
58
testException should contain(exception)
58
59
}
59
60
61
+ private def testBlobNioStringCleaning (input : String , expected : String ) =
62
+ BlobPath .cleanedNioPathString(input) shouldBe expected
63
+
64
+ it should " clean the NIO path string when it has a garbled http protocol" in {
65
+ testBlobNioStringCleaning(
66
+ " https:/lz43.blob.core.windows.net/sc-ebda3e/workspace-services/cbas/terra-app-4628d0e1/test_all_engine_functions/4bb6a0a2-3b07/call-run_read_string/execution/stdout" ,
67
+ " /workspace-services/cbas/terra-app-4628d0e1/test_all_engine_functions/4bb6a0a2-3b07/call-run_read_string/execution/stdout"
68
+ )
69
+ }
70
+
71
+ it should " clean the NIO path string when it has a container name with colon prefix" in {
72
+ testBlobNioStringCleaning(
73
+ " sc-ebda3e:/workspace-services/cbas/terra-app-4628d0e1/test_all_engine_functions/4bb6a0a2-3b07/call-run_read_string/execution/stdout" ,
74
+ " /workspace-services/cbas/terra-app-4628d0e1/test_all_engine_functions/4bb6a0a2-3b07/call-run_read_string/execution/stdout"
75
+ )
76
+ }
77
+
78
+ it should " clean the NIO path string when it's an in-container absolute path" in {
79
+ testBlobNioStringCleaning(
80
+ " /workspace-services/cbas/terra-app-4628d0e1/test_all_engine_functions/4bb6a0a2-3b07/call-run_read_string/execution/stdout" ,
81
+ " /workspace-services/cbas/terra-app-4628d0e1/test_all_engine_functions/4bb6a0a2-3b07/call-run_read_string/execution/stdout"
82
+ )
83
+ }
84
+
85
+ it should " clean the NIO path string when it's the root directory only" in {
86
+ testBlobNioStringCleaning(
87
+ " sc-ebda3e:" ,
88
+ " "
89
+ )
90
+ }
91
+
92
+ // // The below tests are IGNORED because they depend on Azure auth information being present in the environment ////
93
+ val subscriptionId = SubscriptionId (UUID .fromString(" 62b22893-6bc1-46d9-8a90-806bb3cce3c9" ))
94
+
95
+ ignore should " resolve an absolute path string correctly to a path" in {
96
+ val endpoint = BlobPathBuilderSpec .buildEndpoint(" coaexternalstorage" )
97
+ val store = BlobContainerName (" inputs" )
98
+ val blobTokenGenerator = NativeBlobSasTokenGenerator (store, endpoint, Some (subscriptionId))
99
+ val fsm : BlobFileSystemManager = new BlobFileSystemManager (store, endpoint, 10 , blobTokenGenerator)
100
+
101
+ val rootString = s " ${endpoint.value}/ ${store.value}/cromwell-execution "
102
+ val blobRoot : BlobPath = new BlobPathBuilder (store, endpoint)(fsm) build rootString getOrElse fail()
103
+ blobRoot.toAbsolutePath.pathAsString should equal (" https://coaexternalstorage.blob.core.windows.net/inputs/cromwell-execution" )
104
+ val otherFile = blobRoot.resolve(" https://coaexternalstorage.blob.core.windows.net/inputs/cromwell-execution/test/inputFile.txt" )
105
+ otherFile.toAbsolutePath.pathAsString should equal (" https://coaexternalstorage.blob.core.windows.net/inputs/cromwell-execution/test/inputFile.txt" )
106
+ }
107
+
60
108
ignore should " build a blob path from a test string and read a file" in {
61
109
val endpoint = BlobPathBuilderSpec .buildEndpoint(" coaexternalstorage" )
62
110
val endpointHost = BlobPathBuilder .parseURI(endpoint.value).map(_.getHost).getOrElse(fail(" Could not parse URI" ))
63
111
val store = BlobContainerName (" inputs" )
64
112
val evalPath = " /test/inputFile.txt"
65
- val blobTokenGenerator = NativeBlobSasTokenGenerator (store, endpoint)
113
+ val blobTokenGenerator = NativeBlobSasTokenGenerator (store, endpoint, Some (subscriptionId) )
66
114
val fsm : BlobFileSystemManager = new BlobFileSystemManager (store, endpoint, 10L , blobTokenGenerator)
67
115
val testString = endpoint.value + " /" + store + evalPath
68
116
val blobPath : BlobPath = new BlobPathBuilder (store, endpoint)(fsm) build testString getOrElse fail()
@@ -80,7 +128,7 @@ class BlobPathBuilderSpec extends AnyFlatSpec with Matchers with MockSugar {
80
128
val endpoint = BlobPathBuilderSpec .buildEndpoint(" coaexternalstorage" )
81
129
val store = BlobContainerName (" inputs" )
82
130
val evalPath = " /test/inputFile.txt"
83
- val blobTokenGenerator = NativeBlobSasTokenGenerator (store, endpoint)
131
+ val blobTokenGenerator = NativeBlobSasTokenGenerator (store, endpoint, Some (subscriptionId) )
84
132
val fsm : BlobFileSystemManager = new BlobFileSystemManager (store, endpoint, 10 , blobTokenGenerator)
85
133
val testString = endpoint.value + " /" + store + evalPath
86
134
val blobPath1 : BlobPath = new BlobPathBuilder (store, endpoint)(fsm) build testString getOrElse fail()
@@ -95,7 +143,7 @@ class BlobPathBuilderSpec extends AnyFlatSpec with Matchers with MockSugar {
95
143
ignore should " resolve a path without duplicating container name" in {
96
144
val endpoint = BlobPathBuilderSpec .buildEndpoint(" coaexternalstorage" )
97
145
val store = BlobContainerName (" inputs" )
98
- val blobTokenGenerator = NativeBlobSasTokenGenerator (store, endpoint)
146
+ val blobTokenGenerator = NativeBlobSasTokenGenerator (store, endpoint, Some (subscriptionId) )
99
147
val fsm : BlobFileSystemManager = new BlobFileSystemManager (store, endpoint, 10 , blobTokenGenerator)
100
148
101
149
val rootString = s " ${endpoint.value}/ ${store.value}/cromwell-execution "
0 commit comments