11package backend
22
3+ import com .scalableminds .util .accesscontext .TokenContext
34import com .scalableminds .util .tools .Fox
45import org .scalatestplus .play .PlaySpec
56
@@ -26,6 +27,8 @@ import scala.concurrent.ExecutionContext.{global => globalExecutionContext}
2627class DataVaultTestSuite extends PlaySpec {
2728
2829 val handleFoxJustification = " Handling Fox in Unit Test Context"
30+ val emptyTokenContext : TokenContext = TokenContext (None )
31+ val dummyDataStoreHost = " example.com"
2932
3033 " Data vault" when {
3134 " using Range requests" when {
@@ -36,10 +39,11 @@ class DataVaultTestSuite extends PlaySpec {
3639 " return correct response" in {
3740 WsTestClient .withClient { ws =>
3841 val uri = new URI (" http://storage.googleapis.com/" )
39- val vaultPath = new VaultPath (uri, HttpsDataVault .create(RemoteSourceDescriptor (uri, None ), ws))
42+ val vaultPath =
43+ new VaultPath (uri, HttpsDataVault .create(RemoteSourceDescriptor (uri, None ), ws, dummyDataStoreHost))
4044 val bytes =
4145 (vaultPath / s " neuroglancer-fafb-data/fafb_v14/fafb_v14_orig/ $dataKey" )
42- .readBytes(Some (range))(globalExecutionContext)
46+ .readBytes(Some (range))(globalExecutionContext, emptyTokenContext )
4347 .get(handleFoxJustification)
4448
4549 assert(bytes.length == range.length)
@@ -53,7 +57,9 @@ class DataVaultTestSuite extends PlaySpec {
5357 val vaultPath = new VaultPath (uri, GoogleCloudDataVault .create(RemoteSourceDescriptor (uri, None )))
5458 " return correct response" in {
5559
56- val bytes = (vaultPath / dataKey).readBytes(Some (range))(globalExecutionContext).get(handleFoxJustification)
60+ val bytes = (vaultPath / dataKey)
61+ .readBytes(Some (range))(globalExecutionContext, emptyTokenContext)
62+ .get(handleFoxJustification)
5763
5864 assert(bytes.length == range.length)
5965 assert(bytes.take(10 ).sameElements(Array (- 1 , - 40 , - 1 , - 32 , 0 , 16 , 74 , 70 , 73 , 70 )))
@@ -63,15 +69,15 @@ class DataVaultTestSuite extends PlaySpec {
6369 " requesting a non-existent object" in {
6470 val result =
6571 (vaultPath / s " non-existent-key ${UUID .randomUUID}" )
66- .readBytes()(globalExecutionContext)
72+ .readBytes()(globalExecutionContext, emptyTokenContext )
6773 .await(handleFoxJustification)
6874 assertBoxEmpty(result)
6975 }
7076 }
7177 " return failure" when {
7278 " requesting invalid range" in {
7379 val result = (vaultPath / dataKey)
74- .readBytes(Some (Range .Long (- 5 , - 10 , 1 )))(globalExecutionContext)
80+ .readBytes(Some (Range .Long (- 5 , - 10 , 1 )))(globalExecutionContext, emptyTokenContext )
7581 .await(handleFoxJustification)
7682 assertBoxFailure(result)
7783 }
@@ -83,7 +89,7 @@ class DataVaultTestSuite extends PlaySpec {
8389 uri,
8490 Some (GoogleServiceAccountCredential (" name" , JsString (" secret" ), " user" , " org" )))))
8591 val result = (vaultPath / dataKey)
86- .readBytes(Some (Range .Long (- 10 , 10 , 1 )))(globalExecutionContext)
92+ .readBytes(Some (Range .Long (- 10 , 10 , 1 )))(globalExecutionContext, emptyTokenContext )
8793 .await(handleFoxJustification)
8894 assertBoxFailure(result)
8995 }
@@ -97,7 +103,9 @@ class DataVaultTestSuite extends PlaySpec {
97103 val vaultPath =
98104 new VaultPath (uri, S3DataVault .create(RemoteSourceDescriptor (uri, None ), ws)(globalExecutionContext))
99105 val bytes =
100- (vaultPath / " s0/5/5/5" ).readBytes(Some (range))(globalExecutionContext).get(handleFoxJustification)
106+ (vaultPath / " s0/5/5/5" )
107+ .readBytes(Some (range))(globalExecutionContext, emptyTokenContext)
108+ .get(handleFoxJustification)
101109 assert(bytes.length == range.length)
102110 assert(bytes.take(10 ).sameElements(Array (0 , 0 , 0 , 3 , 0 , 0 , 0 , 64 , 0 , 0 )))
103111 }
@@ -113,9 +121,10 @@ class DataVaultTestSuite extends PlaySpec {
113121 " return correct response" in {
114122 WsTestClient .withClient { ws =>
115123 val uri = new URI (" http://storage.googleapis.com/" )
116- val vaultPath = new VaultPath (uri, HttpsDataVault .create(RemoteSourceDescriptor (uri, None ), ws))
124+ val vaultPath =
125+ new VaultPath (uri, HttpsDataVault .create(RemoteSourceDescriptor (uri, None ), ws, dummyDataStoreHost))
117126 val bytes = (vaultPath / s " neuroglancer-fafb-data/fafb_v14/fafb_v14_orig/ $dataKey" )
118- .readBytes()(globalExecutionContext)
127+ .readBytes()(globalExecutionContext, emptyTokenContext )
119128 .get(handleFoxJustification)
120129
121130 assert(bytes.length == dataLength)
@@ -128,7 +137,8 @@ class DataVaultTestSuite extends PlaySpec {
128137 " return correct response" in {
129138 val uri = new URI (" gs://neuroglancer-fafb-data/fafb_v14/fafb_v14_orig" )
130139 val vaultPath = new VaultPath (uri, GoogleCloudDataVault .create(RemoteSourceDescriptor (uri, None )))
131- val bytes = (vaultPath / dataKey).readBytes()(globalExecutionContext).get(handleFoxJustification)
140+ val bytes =
141+ (vaultPath / dataKey).readBytes()(globalExecutionContext, emptyTokenContext).get(handleFoxJustification)
132142
133143 assert(bytes.length == dataLength)
134144 assert(bytes.take(10 ).sameElements(Array (- 1 , - 40 , - 1 , - 32 , 0 , 16 , 74 , 70 , 73 , 70 )))
@@ -143,7 +153,7 @@ class DataVaultTestSuite extends PlaySpec {
143153 new VaultPath (uri, S3DataVault .create(RemoteSourceDescriptor (uri, None ), ws)(globalExecutionContext))
144154 val bytes =
145155 (vaultPath / " 33792-34304_29696-30208_3216-3232" )
146- .readBytes()(globalExecutionContext)
156+ .readBytes()(globalExecutionContext, emptyTokenContext )
147157 .get(handleFoxJustification)
148158 assert(bytes.take(10 ).sameElements(Array (- 87 , - 95 , - 85 , - 94 , - 101 , 124 , 115 , 100 , 113 , 111 )))
149159 }
@@ -155,7 +165,8 @@ class DataVaultTestSuite extends PlaySpec {
155165 WsTestClient .withClient { ws =>
156166 val s3DataVault = S3DataVault .create(RemoteSourceDescriptor (uri, None ), ws)(globalExecutionContext)
157167 val vaultPath = new VaultPath (uri, s3DataVault)
158- val result = vaultPath.readBytes()(globalExecutionContext).await(handleFoxJustification)
168+ val result =
169+ vaultPath.readBytes()(globalExecutionContext, emptyTokenContext).await(handleFoxJustification)
159170 assertBoxEmpty(result)
160171 }
161172 }
@@ -167,7 +178,8 @@ class DataVaultTestSuite extends PlaySpec {
167178 WsTestClient .withClient { ws =>
168179 val s3DataVault = S3DataVault .create(RemoteSourceDescriptor (uri, None ), ws)(globalExecutionContext)
169180 val vaultPath = new VaultPath (uri, s3DataVault)
170- val result = vaultPath.readBytes()(globalExecutionContext).await(handleFoxJustification)
181+ val result =
182+ vaultPath.readBytes()(globalExecutionContext, emptyTokenContext).await(handleFoxJustification)
171183 assertBoxEmpty(result)
172184 }
173185 }
@@ -207,7 +219,8 @@ class DataVaultTestSuite extends PlaySpec {
207219 " using vault path" when {
208220 class MockDataVault extends DataVault {
209221 override def readBytesAndEncoding (path : VaultPath , range : RangeSpecifier )(
210- implicit ec : ExecutionContext ): Fox [(Array [Byte ], Encoding .Value )] = ???
222+ implicit ec : ExecutionContext ,
223+ tc : TokenContext ): Fox [(Array [Byte ], Encoding .Value )] = ???
211224
212225 override def listDirectory (path : VaultPath ,
213226 maxItems : Int )(implicit ec : ExecutionContext ): Fox [List [VaultPath ]] = ???
0 commit comments