Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Commit 45dfb82

Browse files
committed
Merge pull request mulesoft#183 from mseashor/master
Don't unset credentials when switching endpoints
2 parents 837af70 + 09ca6e2 commit 45dfb82

File tree

11 files changed

+89
-7
lines changed

11 files changed

+89
-7
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ before_script:
1111
- node_modules/grunt-protractor-runner/node_modules/protractor/bin/webdriver-manager update
1212
before_install:
1313
- "export DISPLAY=:99.0"
14-
- "sh -e /etc/init.d/xvfb start"
14+
#startup Xvfb manually to increase display size. Prevents selenium issues.
15+
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
1516
after_success:
1617
- echo -n $id_rsa_{00..30} >> ~/.ssh/id_rsa_base64
1718
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa

dist/scripts/api-console-vendor.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/scripts/api-console.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@
472472
$scope.showMoreEnable = true;
473473
$scope.showSpinner = false;
474474
$scope.securitySchemes = $scope.methodInfo.securitySchemes();
475-
$scope.credentials = {};
476475
$scope.traits = $scope.readTraits($scope.methodInfo.is);
477476
$scope.context.customParameters = { headers: [], queryParameters: [] };
478477
$scope.currentBodySelected = methodInfo.body ? Object.keys(methodInfo.body)[0] : 'application/json';
@@ -1752,6 +1751,7 @@
17521751
$scope.disableTitle = false;
17531752
$scope.resourcesCollapsed = false;
17541753
$scope.documentationCollapsed = false;
1754+
$scope.credentials = {};
17551755

17561756
if ($attrs.hasOwnProperty('singleView')) {
17571757
$scope.singleView = true;

dist/scripts/api-console.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/directives/method-list.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
$scope.showMoreEnable = true;
113113
$scope.showSpinner = false;
114114
$scope.securitySchemes = $scope.methodInfo.securitySchemes();
115-
$scope.credentials = {};
116115
$scope.traits = $scope.readTraits($scope.methodInfo.is);
117116
$scope.context.customParameters = { headers: [], queryParameters: [] };
118117
$scope.currentBodySelected = methodInfo.body ? Object.keys(methodInfo.body)[0] : 'application/json';

src/app/resources/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
$scope.disableTitle = false;
1515
$scope.resourcesCollapsed = false;
1616
$scope.documentationCollapsed = false;
17+
$scope.credentials = {};
1718

1819
if ($attrs.hasOwnProperty('singleView')) {
1920
$scope.singleView = true;

test/regression/assertions/resource.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,37 @@ function Resource (poName) {
5050
}
5151
});
5252
};
53+
54+
this.ifCredentialsUpdateBetweenResources = function () {
55+
var resourcesGetButton= this.po.getMethodBtn(0, 0);
56+
var pageObject = this.po;
57+
58+
var userText = 'test';
59+
var passwordText = 'pass';
60+
61+
//click Get on /resources and set the user/pass
62+
resourcesGetButton.click();
63+
64+
var username = pageObject.getUsernameField();
65+
username.sendKeys(userText);
66+
var password = pageObject.getPasswordField();
67+
password.sendKeys(passwordText);
68+
69+
//close button to ensure 'resource2' is on screen.
70+
var closeButton = pageObject.getCloseBtn(0);
71+
closeButton.click();
72+
73+
var resources2GetButton = pageObject.getMethodBtn(1, 0);
74+
75+
//click Get on /resources2 and ensure user/pass match
76+
resources2GetButton.click();
77+
78+
var username2 = pageObject.getUsernameField();
79+
expect(username2.getAttribute('value')).toBe(userText);
80+
var password2 = pageObject.getPasswordField();
81+
expect(password2.getAttribute('value')).toBe(passwordText);
82+
83+
};
5384
}
5485

5586

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>API Console</title>
7+
<link href="styles/api-console-light-theme.css" rel="stylesheet" class="theme">
8+
</head>
9+
<body ng-app="ramlConsoleApp" ng-cloak class="raml-console-body">
10+
<raml-console src="raml/security-schemes-basic.raml"></raml-console>
11+
<script src="scripts/api-console-vendor.js"></script>
12+
<script src="scripts/api-console.js"></script>
13+
<script type="text/javascript">
14+
$.noConflict();
15+
</script>
16+
</body>
17+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#%RAML 0.8
2+
title: My API
3+
baseUri: http://localhost:9000
4+
securitySchemes:
5+
- basic:
6+
type: Basic Authentication
7+
8+
securedBy: [ basic ]
9+
/resources:
10+
get:
11+
/resources2:
12+
get:

test/regression/page_objects/resourcePO.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ function ResourcesPO () {
4141
this.getSecuritySchemes = function (index) {
4242
return this.resources.get(index+1).all(by.tagName('option'));
4343
};
44+
this.getUsernameField = function () {
45+
return element(by.name('username'));
46+
};
47+
this.getPasswordField = function () {
48+
return element(by.name('password'));
49+
};
50+
this.getCloseBtn = function (index) {
51+
return this.resources.get(index+1).all(by.css('.raml-console-resource-close-btn'));
52+
};
53+
54+
4455
}
4556

4657
ResourcesPO.prototype = basePO;

test/regression/standalone/directiveSpec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ module.exports = function() {
3939
assert.ifShowingSecuritySchemes(0, 0, ['Anonymous', 'OAuth 2.0']);
4040
});
4141

42+
it('should be able to cache credentials between resources', function () {
43+
// Arrange
44+
var assert = assertions.create('resource');
45+
46+
// Act
47+
browser.get('http://localhost:9000/directive-security-schemes-basic.html');
48+
assert.ifCredentialsUpdateBetweenResources();
49+
});
50+
51+
4252
it('should be able to diplay all HTTP methods', function () {
4353
// Arrange
4454
var assert = assertions.create('resource');

0 commit comments

Comments
 (0)