Skip to content

Commit

Permalink
4.1.0: Raise AccessDenied when the liveness check fails.
Browse files Browse the repository at this point in the history
(Merge branch 'jsantos17-1942-permission-denied-s3-datasource')
  • Loading branch information
alissapajer committed Sep 19, 2018
2 parents 1501621 + 7f1330f commit 8c789aa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import slamdata.Predef.{Stream => _, _}
import java.time.{ZoneOffset, LocalDateTime}

import cats.effect.{Effect, Timer}
import cats.syntax.applicative._
import cats.syntax.flatMap._
import cats.syntax.functor._
import cats.syntax.option._
import fs2.Stream
import jawn.Facade
Expand All @@ -40,7 +42,6 @@ import pathy.Path
import pathy.Path.{DirName, FileName}
import qdata.QDataEncode
import qdata.json.QDataFacade
import scalaz.syntax.applicative._
import scalaz.{\/-, -\/, OptionT}
import shims._

Expand Down Expand Up @@ -127,7 +128,7 @@ object S3DataSource {
case None => req
}

requestSigning >>= (s => s.signedHeaders[F](req0).map(h => req0.withHeaders(h)))
requestSigning >>= (_.signedHeaders[F](req0).map(req0.withHeaders(_)))
}
}
case None => req => req.pure[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ package quasar.physical.s3


import quasar.Disposable
import quasar.api.datasource.DatasourceError.{
InitializationError,
InvalidConfiguration,
MalformedConfiguration
}
import quasar.api.datasource.DatasourceError
import quasar.api.datasource.DatasourceError.InitializationError
import quasar.api.datasource.DatasourceType
import quasar.api.resource.ResourcePath
import quasar.connector.Datasource
Expand All @@ -35,9 +32,9 @@ import fs2.Stream
import org.http4s.client.blaze.Http1Client
import scalaz.{\/, NonEmptyList}
import scalaz.syntax.either._
import scalaz.syntax.applicative._
import scalaz.syntax.bind._
import scalaz.syntax.std.option._
import cats.syntax.applicative._
import cats.syntax.flatMap._
import cats.syntax.option._
import shims._
import slamdata.Predef.{Stream => _, _}

Expand All @@ -53,22 +50,22 @@ object S3DataSourceModule extends LightweightDatasourceModule {
val ds: Datasource[F, Stream[F, ?], ResourcePath] = s3Ds

s3Ds.isLive.ifM({
val disposable = Disposable(ds, client.shutdown)

disposable.right[InitializationError[Json]].point[F]
}, {
Disposable(ds, client.shutdown).right.pure[F]
},
{
val msg = "Unable to ListObjects at the root of the bucket"
val err: InitializationError[Json] =
InvalidConfiguration(s3.datasourceKind, config, NonEmptyList(msg))

err.left[Disposable[F, Datasource[F, Stream[F, ?], ResourcePath]]].point[F]
DatasourceError
.accessDenied[Json, InitializationError[Json]](kind, config, msg)
.left.pure[F]
})
}
}

case Left((msg, _)) =>
(MalformedConfiguration(kind, config, msg): InitializationError[Json])
.left[Disposable[F, Datasource[F, Stream[F, ?], ResourcePath]]].point[F]
DatasourceError
.invalidConfiguration[Json, InitializationError[Json]](kind, config, NonEmptyList(msg))
.left.pure[F]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package quasar.physical.s3

import slamdata.Predef._

import quasar.api.datasource.DatasourceError.InvalidConfiguration
import quasar.api.datasource.DatasourceError.AccessDenied
import quasar.connector.ResourceError
import quasar.contrib.scalaz.MonadError_

Expand All @@ -41,7 +41,7 @@ class S3DataSourceModuleSpec extends Specification {
val ds = S3DataSourceModule.lightweightDatasource[IO](conf).unsafeRunSync.toEither

ds must beLike {
case Left(InvalidConfiguration(_, _, _)) => ok
case Left(AccessDenied(_, _, _)) => ok
}
}

Expand All @@ -53,7 +53,7 @@ class S3DataSourceModuleSpec extends Specification {
val ds = S3DataSourceModule.lightweightDatasource[IO](conf).unsafeRunSync.toEither

ds must beLike {
case Left(InvalidConfiguration(_, _, _)) => ok
case Left(AccessDenied(_, _, _)) => ok
}
}

Expand Down
2 changes: 1 addition & 1 deletion quasar-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
68.2.0
69.0.1
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "4.0.3"
version in ThisBuild := "4.1.0"

0 comments on commit 8c789aa

Please sign in to comment.