Skip to content

Commit

Permalink
Merge branch 'release/1.19.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtgck committed Nov 26, 2018
2 parents 6b468a7 + bdd298a commit d5c52e4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [1.19.3] - 2018-11-26
### Added
- Support Glitch

## [1.19.2] - 2018-11-13
### Fixed
- Fix to delete the file if store process is failed
Expand Down
10 changes: 3 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbtassembly.AssemblyPlugin.autoImport.assemblyJarName

name := "trans-server-akka"

version := "1.19.2"
version := "1.19.3"

scalaVersion := "2.11.12"

Expand All @@ -29,12 +29,8 @@ lazy val root = (project in file(".")).

libraryDependencies ++= Seq(
// sbt from http://akka.io/docs/
"com.typesafe.akka" %% "akka-http-core" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-jackson" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-xml" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test,

// Slick
"com.typesafe.slick" %% "slick" % "3.1.1",
Expand All @@ -45,6 +41,6 @@ lazy val root = (project in file(".")).
"com.github.scopt" %% "scopt" % "3.6.0",

// ScalaTest
"org.scalatest" %% "scalatest" % "2.2.6" % "test"
"org.scalatest" %% "scalatest" % "2.2.6" % Test
)
)
4 changes: 1 addition & 3 deletions src/main/scala/io/github/nwtgck/trans_server/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package io.github.nwtgck.trans_server

import java.io.File
import java.nio.file.StandardOpenOption
import javax.crypto.Cipher

import akka.actor.ActorSystem
import akka.event.Logging
import akka.http.impl.model.parser.HeaderParser
import javax.crypto.Cipher
import akka.http.scaladsl.model.Multipart.FormData.BodyPart
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{HttpOrigin, RawHeader}
import akka.http.scaladsl.server.directives.Credentials
import akka.http.scaladsl.server.{Directive0, Route}
import akka.stream.scaladsl.{Broadcast, Compression, FileIO, Flow, GraphDSL, Keep, RunnableGraph, Sink, Source}
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/io/github/nwtgck/trans_server/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ object Util {

extractUri{uri =>
optionalHeaderValueByName("X-Forwarded-Proto") {
case Some(xForwardedProto) if xForwardedProto != "https" =>
// NOTE: `xForwardedProto != "https"` should be OK, but Glitch gives like "https,http,http"
case Some(xForwardedProto) if !xForwardedProto.contains("https") =>
redirect(
uri.copy(scheme = "https"),
StatusCodes.PermanentRedirect
Expand Down
13 changes: 12 additions & 1 deletion src/test/scala/io/github/nwtgck/trans_server/CoreSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,24 @@ class CoreSpec extends FunSpec with ScalatestRouteTest with Matchers with Before
}
}

it("should show redirect page if X-Forwarded-Proto header is specified") {
it("should redirect page if X-Forwarded-Proto header is specified") {
Get(s"/") ~> addHeader("X-Forwarded-Proto", "http") ~> core.route ~> check {
// Status should be "Permanent Redirect"
status shouldBe StatusCodes.PermanentRedirect
}
}

// NOTE: Should test but error, "java.lang.IllegalArgumentException: Illegal HTTP header 'X-Forwarded-Proto': Invalid input ',', expected scheme-char or 'EOI'"
if(false) {
it("should not redirect page if X-Forwarded-Proto header is https,http,http for Glitch") {
Get(s"/") ~> addHeader("X-Forwarded-Proto", "https,http,http") ~> core.route ~> check {
// Status should NOT be "Permanent Redirect"
// Just check status code
status.intValue() shouldBe 200
}
}
}

it("should redirect from top page if enable-top-page-https-redirect is true") {
// Create a memory-base db
val db = Database.forConfig("h2mem-trans")
Expand Down

0 comments on commit d5c52e4

Please sign in to comment.