Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Commit

Permalink
#3, test: Unit tests for security template
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaschmidt committed Mar 7, 2016
1 parent 3f0999f commit cb84bbb
Show file tree
Hide file tree
Showing 7 changed files with 717 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/src/main/scala/de/zalando/play/controllers/security.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.zalando.play.controllers

/**
* @author slasch
* @since 05.03.2016.
*/
class security {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package basic.auth.api.yaml

import play.api.mvc._
import Security.AuthenticatedBuilder
import de.zalando.play.controllers.PlayBodyParsing


trait BasicAuthApiYamlSecurity {

def basicAuth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val basicAuth_Checks = Seq(basicAuth_Extractor _)

class basicAuth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = basicAuth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)


private def onUnauthorized[C](mimeType: String, content: C): RequestHeader => Result =_ => {
implicit val writeable = PlayBodyParsing.anyToWritable[C](mimeType)
Results.Unauthorized(content)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package full.petstore.api.yaml

import play.api.mvc._
import Security.AuthenticatedBuilder
import de.zalando.play.controllers.PlayBodyParsing
import de.zalando.play.controllers.ArrayWrapper
import org.joda.time.DateTime


trait FullPetstoreApiYamlSecurity {

def petstore_auth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val petstore_auth_Checks = Seq(petstore_auth_Extractor _)

class petstore_auth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = petstore_auth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)








def petstore_auth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val petstore_auth_Checks = Seq(petstore_auth_Extractor _)

class petstore_auth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = petstore_auth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)


def petstore_auth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val petstore_auth_Checks = Seq(petstore_auth_Extractor _)

class petstore_auth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = petstore_auth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)






def api_key_Extractor[User >: Any](header: RequestHeader): Option[User] = ???
def petstore_auth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val api_key_petstore_auth_Checks = Seq(api_key_Extractor _, petstore_auth_Extractor _)

class api_key_petstore_auth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = api_key_petstore_auth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)


def petstore_auth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val petstore_auth_Checks = Seq(petstore_auth_Extractor _)

class petstore_auth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = petstore_auth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)


def petstore_auth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val petstore_auth_Checks = Seq(petstore_auth_Extractor _)

class petstore_auth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = petstore_auth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)


def petstore_auth_Extractor[User >: Any](header: RequestHeader): Option[User] = ???

val petstore_auth_Checks = Seq(petstore_auth_Extractor _)

class petstore_auth_Action(mimeType: String, unauthorizedContent: Any) extends AuthenticatedBuilder(
req => {
val individualChecks = petstore_auth_Checks.map(_.apply(req))
individualChecks.find(_.isEmpty).getOrElse(Option(individualChecks.flatten))
},
onUnauthorized(mimeType, unauthorizedContent)
)



private def onUnauthorized[C](mimeType: String, content: C): RequestHeader => Result =_ => {
implicit val writeable = PlayBodyParsing.anyToWritable[C](mimeType)
Results.Unauthorized(content)
}
}
Loading

0 comments on commit cb84bbb

Please sign in to comment.