Skip to content

Commit

Permalink
Misc fixes for getting the ATH going (#10)
Browse files Browse the repository at this point in the history
* [JENKINS-37671] Use Jenkins.getAuthentication() instead of User.impersonate()

* 0.0.9-beta1

* 0.0.9-beta2 - fix url normalization (removing slashes)

* NPM 0.0.9 and Maven 1.9 releases
  • Loading branch information
tfennelly committed Sep 12, 2016
1 parent 6abf978 commit 3cbc124
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@jenkins-cd/sse-gateway",
"version": "0.0.8",
"version": "0.0.9",
"description": "Client API for the Jenkins SSE Gateway plugin. Browser UI push events from Jenkins.",
"main": "src/main/js/index.js",
"files": [
Expand All @@ -26,15 +26,15 @@
},
"homepage": "https://github.com/jenkinsci/sse-gateway-plugin",
"devDependencies": {
"@jenkins-cd/js-builder": "0.0.39",
"@jenkins-cd/js-modules": "^0.0.7",
"@jenkins-cd/js-builder": "0.0.40",
"@jenkins-cd/js-modules": "0.0.8",
"@jenkins-cd/js-test": "^1.2.3",
"gulp": "^3.9.1",
"http-proxy": "^1.14.0",
"wait-until-promise": "^1.0.0"
},
"peerDependencies": {
"@jenkins-cd/js-modules": "^0.0.7"
"@jenkins-cd/js-modules": "^0.0.8"
},
"dependencies": {
"@jenkins-cd/diag": "0.0.2",
Expand Down
Expand Up @@ -156,7 +156,7 @@ public boolean subscribe(@Nonnull EventFilter filter) {

User current = getUser();
if (current != null) {
authentication = current.impersonate();
authentication = Jenkins.getAuthentication();
} else {
authentication = Jenkins.ANONYMOUS;
}
Expand Down
21 changes: 11 additions & 10 deletions src/main/js/sse-client.js
Expand Up @@ -71,16 +71,16 @@ function scheduleDoConfigure(delay) {
}
nextDoConfigureTimeout = setTimeout(doConfigure, timeoutDelay);
}
function discoverJenkinsUrl() {
jenkinsUrl = jsModules.getRootURL();
if (!jenkinsUrl) {
jenkinsUrl = '';
} else {
// only in tests, this is suffixed ...
while (jenkinsUrl.charAt(jenkinsUrl.length - 1) === '/') {
jenkinsUrl = jenkinsUrl.substring(0, jenkinsUrl.length - 1);
}
function normalizeUrl(url) {
if (!url) {
return '';
}
// remove trailing slashes
var newUrl = url;
while (newUrl.charAt(newUrl.length - 1) === '/') {
newUrl = newUrl.substring(0, newUrl.length - 1);
}
return newUrl;
}

exports.configure = function (config) {
Expand Down Expand Up @@ -128,8 +128,9 @@ exports.connect = function (clientId, onConnect) {
}

if (!jenkinsUrl) {
discoverJenkinsUrl();
jenkinsUrl = jsModules.getRootURL();
}
jenkinsUrl = normalizeUrl(jenkinsUrl);
exports.jenkinsUrl = jenkinsUrl;

if (typeof clientId !== 'string') {
Expand Down

0 comments on commit 3cbc124

Please sign in to comment.