From b4ce3e28e77859c05b1989342cc8f0ce6fe85a06 Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Fri, 21 Apr 2017 10:59:15 -0600 Subject: [PATCH] Fix outgoing example URL in API backend form not containing right host. --- .../admin-ui/app/components/apis/url-match-form.js | 2 +- src/api-umbrella/admin-ui/app/models/api.js | 6 +++--- .../app/templates/components/apis/url-match-table.hbs | 2 +- test/admin_ui/test_apis.rb | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/api-umbrella/admin-ui/app/components/apis/url-match-form.js b/src/api-umbrella/admin-ui/app/components/apis/url-match-form.js index d9f3bcc03..4e8658b2a 100644 --- a/src/api-umbrella/admin-ui/app/components/apis/url-match-form.js +++ b/src/api-umbrella/admin-ui/app/components/apis/url-match-form.js @@ -26,7 +26,7 @@ export default Ember.Component.extend({ }), exampleOutgoingUrl: Ember.computed('bufferedModel.frontendPrefix', 'bufferedModel.backendPrefix', function() { - let root = this.get('apiExampleIncomingUrlRoot') || ''; + let root = this.get('apiExampleOutgoingUrlRoot') || ''; let prefix = this.get('bufferedModel.backendPrefix') || this.get('bufferedModel.frontendPrefix') || ''; return root + prefix + this.get('exampleSuffix'); }), diff --git a/src/api-umbrella/admin-ui/app/models/api.js b/src/api-umbrella/admin-ui/app/models/api.js index 5e992d5bc..5500e9dc3 100644 --- a/src/api-umbrella/admin-ui/app/models/api.js +++ b/src/api-umbrella/admin-ui/app/models/api.js @@ -59,11 +59,11 @@ export default DS.Model.extend(Validations, { }, exampleIncomingUrlRoot: Ember.computed('frontendHost', function() { - return 'http://' + (this.get('frontendHost') || ''); + return 'https://' + (this.get('frontendHost') || ''); }), - exampleOutgoingUrlRoot: Ember.computed('backendHost', function() { - return 'http://' + (this.get('backendHost') || this.get('frontendHost') || ''); + exampleOutgoingUrlRoot: Ember.computed('backendProtocol', 'backendHost', 'fontendHost', function() { + return this.get('backendProtocol') + '://' + (this.get('backendHost') || this.get('frontendHost') || ''); }), }).reopenClass({ urlRoot: '/api-umbrella/v1/apis', diff --git a/src/api-umbrella/admin-ui/app/templates/components/apis/url-match-table.hbs b/src/api-umbrella/admin-ui/app/templates/components/apis/url-match-table.hbs index 03dac6363..e6ca07151 100644 --- a/src/api-umbrella/admin-ui/app/templates/components/apis/url-match-table.hbs +++ b/src/api-umbrella/admin-ui/app/templates/components/apis/url-match-table.hbs @@ -1,4 +1,4 @@ -{{apis/url-match-form model=urlMatchModel collection=model.urlMatches apiExampleIncomingUrlRoot=model.exampleIncomingUrlRoot openModal=openModal}} +{{apis/url-match-form model=urlMatchModel collection=model.urlMatches apiExampleIncomingUrlRoot=model.exampleIncomingUrlRoot apiExampleOutgoingUrlRoot=model.exampleOutgoingUrlRoot openModal=openModal}}
diff --git a/test/admin_ui/test_apis.rb b/test/admin_ui/test_apis.rb index d10e2a785..f5db90a6c 100644 --- a/test/admin_ui/test_apis.rb +++ b/test/admin_ui/test_apis.rb @@ -116,7 +116,7 @@ def test_form assert_selector(".modal") within(".modal") do fill_in "Host", :with => "google.com" - fill_in "Port", :with => "443" + assert_field("Port", :with => "443") click_button("OK") end @@ -130,6 +130,8 @@ def test_form within(".modal") do fill_in "Frontend Prefix", :with => "/foo" fill_in "Backend Prefix", :with => "/bar" + assert_text("Incoming Frontend Request: https://api.foo.com/fooexample.json?param=value") + assert_text("Outgoing Backend Request: https://api.bar.com/barexample.json?param=value") click_button("OK") end