Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REP-4573 Some tests that totally don't work with japanese characters #1607

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions repose-aggregator/tests/functional-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ task copyConfigs() {
}

integrationTest.dependsOn copyArtifacts, copyConfigs
integrationTest.inputs.dir copyConfigs.outputs
//INFO: Ideally i'd just be able to point to the files output from the copyArtifacts task,
//INFO: but that's a directory where the tests do work so the contents are always moving making gradle rerun the tests
//INFO: This will achieve the desired effect indirectly
integrationTest.inputs.dir configurations.integrationTestRunnable.files
integrationTest.inputs.dir configurations.integrationTestBundle.files

def container = "valve"
def targetHostName = "localhost"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<scripting xmlns="http://docs.openrepose.org/repose/scripting/v1.0"
language="groovy">
def stream = new BufferedInputStream(request.getInputStream())
stream.mark(8000)
def reader = new BufferedReader(new InputStreamReader(stream))
println("***************************buttsbuttsbutts***************************")
println(reader.readLine())
println("***************************buttsbuttsbutts***************************")
stream.reset()
filterChain.doFilter(new org.openrepose.commons.utils.servlet.http.HttpServletRequestWrapper(request, new org.openrepose.commons.utils.io.BufferedServletInputStream(stream)), response)
</scripting>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<system-model xmlns="http://docs.openrepose.org/repose/system-model/v2.0">
<repose-cluster id="repose">

<nodes>
<node id="node1" hostname="localhost" http-port="${reposePort}"/>
</nodes>

<filters>
<filter name="scripting"/>
</filters>

<destinations>
<endpoint id="target" protocol="http" hostname="localhost" root-path="/" port="${targetPort}"
default="true"/>
</destinations>

</repose-cluster>
</system-model>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* _=_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_=
* Repose
* _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
* Copyright (C) 2010 - 2015 Rackspace US, Inc.
* _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_=_
*/
package features.core.languages

import framework.ReposeValveTest
import org.rackspace.deproxy.ApacheClientConnector
import org.rackspace.deproxy.Deproxy
import org.rackspace.deproxy.MessageChain
import spock.lang.Ignore

import static java.nio.charset.StandardCharsets.UTF_8
/**
* Created by adrian on 10/19/16.
*/
class BasicSupportTest extends ReposeValveTest {

def setupSpec() {
deproxy = new Deproxy()
deproxy.addEndpoint(properties.targetPort)

def params = properties.getDefaultTemplateParams()
repose.configurationProvider.applyConfigs("common", params)
repose.configurationProvider.applyConfigs("features/core/languages/basic", params)
repose.start()
repose.waitForNon500FromUrl(properties.reposeEndpoint)
}


def cleanupSpec() {
if (repose) {
repose.stop()
}
if (deproxy) {
deproxy.shutdown()
}
}

@Ignore("Jetty 'helpfully' rejects this one with a 400")
def "send a header with a japanese name"() {

when:
MessageChain mc = deproxy.makeRequest([url: reposeEndpoint + "/resource", method: "get", headers: ['バナナ': 'phone']])

then:
mc.receivedResponse.code == "200"
mc.handlings.get(0).request.headers.getFirstValue('バナナ') == 'phone'
}

@Ignore("""This one is mangled by the time it hits the first filter, not certain if it's us or jetty.
By the time it goes out the backdoor it's no longer usable and gets rejected by deproxy.""")
def "send a header with a japanese value"() {

when:
MessageChain mc = deproxy.makeRequest([url: reposeEndpoint + "/resource", method: "get", headers: ['banana': '電話']])

then:
mc.receivedResponse.code == "200"
mc.handlings.get(0).request.headers.getFirstValue('banana') == '電話'
}

@Ignore("Comes in fine works till we need to go to the origin service, then we encode it and change the url.")
def "send a request with a japanese url"() {

when:
MessageChain mc = deproxy.makeRequest([url: reposeEndpoint + "/ガンダム", method: "get", headers: ['banana': 'phone']])

then:
mc.receivedResponse.code == "200"
mc.handlings.size() == 1
mc.handlings.get(0).request.path.endsWith("/ガンダム")
}

@Ignore("Whelp this transmits fine, but by the time it gets to a filter its gone, not sure if its jetty or repose eating it")
def "send a request with a japanese body"() {

when:
MessageChain mc = deproxy.makeRequest([url: reposeEndpoint + "/resource",
method: "post",
headers: ['banana': 'phone', 'Content-Type': 'application/json; charset=utf-8'],
requestBody: '''{"バナナ": "電話"}'''.getBytes(UTF_8),
clientConnector: new ApacheClientConnector()])

then:
mc.receivedResponse.code == "200"
mc.handlings.size() == 1
mc.handlings.get(0).request.body == '''{"バナナ": "電話"}'''
}
}