-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Johannes Rudolph <[email protected]> revert code format change Update Http2ServerSettings.scala Update Http2ServerSpec.scala rework test - still needs proper asserts refactor tests scalafmt
- Loading branch information
Showing
7 changed files
with
248 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerResetSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* license agreements; and to You under the Apache License, version 2.0: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* This file is part of the Apache Pekko project, which was derived from Akka. | ||
*/ | ||
|
||
/* | ||
* Copyright (C) 2018-2022 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package org.apache.pekko.http.impl.engine.http2 | ||
|
||
import org.apache.pekko | ||
import pekko.http.impl.engine.http2.Http2Protocol.FrameType | ||
import pekko.http.impl.engine.http2.framing.FrameRenderer | ||
import pekko.util.ByteStringBuilder | ||
import org.scalatest.concurrent.Eventually | ||
|
||
import java.nio.ByteOrder | ||
|
||
/** | ||
* This tests the http2 server support for rapid resets. | ||
*/ | ||
class Http2ServerResetSpec extends Http2SpecWithMaterializer(""" | ||
pekko.http.server.remote-address-header = on | ||
pekko.http.server.http2.log-frames = on | ||
""") | ||
with Eventually { | ||
override def failOnSevereMessages: Boolean = false | ||
|
||
"The Http/2 server implementation" should { | ||
"cancel connection during rapid reset attack".inAllStagesStopped(new TestSetup with RequestResponseProbes { | ||
implicit val bigEndian: ByteOrder = ByteOrder.BIG_ENDIAN | ||
val bb = new ByteStringBuilder | ||
bb.putInt(0) | ||
val rstFrame = FrameRenderer.renderFrame(FrameType.RST_STREAM, ByteFlag.Zero, 1, bb.result()) | ||
val longFrame = Seq.fill(1000)(rstFrame).reduce(_ ++ _) | ||
try { | ||
network.sendBytes(longFrame) | ||
} catch { | ||
case assertionError: AssertionError => | ||
assertionError.getMessage should include("message CancelSubscription") | ||
assertionError.getMessage should include("org.apache.pekko.stream.RateExceededException") | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.