-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for node and rnode proxies
- Loading branch information
Showing
6 changed files
with
137 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require 'watir' | ||
require_relative 'e2e_helper' | ||
|
||
describe 'Node and Rnode proxies' do | ||
|
||
def browser | ||
@browser ||= new_browser | ||
end | ||
|
||
before(:all) do | ||
mnts = ["-v", "#{extra_fixtures}:/opt/extras"] | ||
mnts.concat ["-v", "#{portal_fixture('portal_with_proxies.yml')}:/etc/ood/config/ood_portal.yml"] | ||
Rake::Task['test:start_test_container'].execute(mount_args: mnts) | ||
|
||
container_exec("/bin/bash -c '/opt/extras/simple_origin_server.py >/tmp/rnode.out 2>&1 &'") | ||
container_exec("/bin/bash -c 'FLASK_PORT=5001 FLASK_BASE_URL=/node/localhost/5001 /opt/extras/simple_origin_server.py >/tmp/node.out 2>&1 &'") | ||
browser_login(browser) | ||
end | ||
|
||
after(:all) do | ||
Rake::Task['test:stop_test_container'].execute | ||
browser.close | ||
end | ||
|
||
it 'rnode proxies directly to the origin' do | ||
browser.goto "#{ctr_base_url}/rnode/localhost/5000/simple-page" | ||
expect(browser.url).to eq("#{ctr_base_url}/rnode/localhost/5000/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
|
||
it 'rnode redirects to the origin' do | ||
browser.goto "#{ctr_base_url}/rnode/localhost/5000/simple-redirect" | ||
expect(browser.url).to eq("#{ctr_base_url}/rnode/localhost/5000/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
|
||
it 'rnode redirects to the origin when no path is given' do | ||
browser.goto "#{ctr_base_url}/rnode/localhost/5000" | ||
expect(browser.url).to eq("#{ctr_base_url}/rnode/localhost/5000/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
|
||
it 'rnode redirects to the origin when only root is given' do | ||
browser.goto "#{ctr_base_url}/rnode/localhost/5000/" | ||
expect(browser.url).to eq("#{ctr_base_url}/rnode/localhost/5000/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
|
||
it 'node proxies directly to the origin' do | ||
browser.goto "#{ctr_base_url}/node/localhost/5001/simple-page" | ||
expect(browser.url).to eq("#{ctr_base_url}/node/localhost/5001/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
|
||
it 'rnode redirects to the origin' do | ||
browser.goto "#{ctr_base_url}/node/localhost/5001/simple-redirect" | ||
expect(browser.url).to eq("#{ctr_base_url}/node/localhost/5001/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
|
||
it 'node redirects to the origin with nothing extra in the path' do | ||
browser.goto "#{ctr_base_url}/node/localhost/5001" | ||
expect(browser.url).to eq("#{ctr_base_url}/node/localhost/5001/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
|
||
it 'node redirects to the origin when only root is given' do | ||
browser.goto "#{ctr_base_url}/node/localhost/5001/" | ||
expect(browser.url).to eq("#{ctr_base_url}/node/localhost/5001/simple-page") | ||
expect(browser.div(id: "test-div").present?).to be true | ||
end | ||
end |
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,11 @@ | ||
--- | ||
# | ||
# Portal configuration | ||
# | ||
|
||
listen_addr_port: 8080 | ||
servername: localhost | ||
port: 8080 | ||
|
||
rnode_uri: '/rnode' | ||
node_uri: '/node' |
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,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from flask import Flask, redirect, request, Blueprint, url_for | ||
|
||
app = Blueprint('app', 'simple_origin_server_blueprint') | ||
|
||
@app.route("/one/two/three/relative-redirect") | ||
def relative_redirect(): | ||
return redirect(url_for('app.one_level_down'), code=302) | ||
|
||
@app.route("/one/one-level-down") | ||
def one_level_down(): | ||
simple_page() | ||
|
||
@app.route("/simple-redirect") | ||
def simple_redirect(): | ||
return redirect(url_for('app.simple_page'), code=302) | ||
|
||
@app.route('/') | ||
def root(): | ||
return redirect(url_for('app.simple_page'), code=302) | ||
|
||
@app.route("/simple-page") | ||
def simple_page(): | ||
return "<html><body><div id='test-div'>A very simple page for testing</div></body></html>" | ||
|
||
if __name__ == '__main__': | ||
super_app = Flask(__name__) | ||
|
||
if os.environ.get('FLASK_BASE_URL'): | ||
print('app root is ' + os.environ.get('FLASK_BASE_URL')) | ||
super_app.register_blueprint(app, url_prefix=os.environ.get('FLASK_BASE_URL')) | ||
else: | ||
super_app.register_blueprint(app, url_prefix='/') | ||
|
||
if os.environ.get('FLASK_PORT'): | ||
port = int(os.environ.get('FLASK_PORT')) | ||
else: | ||
port = 5000 | ||
|
||
print(super_app.url_map) | ||
super_app.run(host='127.0.0.1', port=port, debug=True) |