bastion 3.3.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0d3d2dd8dba1c9d5e1e7ec97ea470cbbbf010b5
4
- data.tar.gz: e1822a868e460069a8a2631f3a6987aaca73bd3c
3
+ metadata.gz: 934c64b4816522e752daec9c8b7c72ef01d45bd3
4
+ data.tar.gz: 04aaeabc596dcf24f88a387e93db7f7baf401236
5
5
  SHA512:
6
- metadata.gz: b93d2e4416c5c77596546b67ecf596bd33c15aee450adc461fb1d274bde2ff747ffa73033281fe9cfa61b511888760ff2cf9a017a3921e9a73520a50b152ca94
7
- data.tar.gz: 12d400337473db4c91e0e956974eacfbb5e3a6ccd873747323c5ff849a6df3416a05c3cd3a6603eb1d06893e7bb94c47fd6702fa835f4d02158084645d26cacd
6
+ metadata.gz: eff2f889f6f0c1fc3edcbcae5ef61c9742511d5e455eb67cd76c8452f0e36762392ab292d4a1a6cfc58ba3bda1d2bac481f0a514dc6dbd275f965ccb5d48c436
7
+ data.tar.gz: eddef0aa5ec9034aa877e933b15e44e4faba35dafc2baf2bc1b925e420ad6cfad71d2fc4e52b52ab28974f431d4cd4c4bdd7a60cd4c1f4d68b7fa0277dabdad8
@@ -5,7 +5,7 @@
5
5
  * @description
6
6
  * Module for auth functionality.
7
7
  */
8
- angular.module('Bastion.auth', ['Bastion']);
8
+ angular.module('Bastion.auth', []);
9
9
 
10
10
  /**
11
11
  * @ngdoc object
@@ -32,4 +32,8 @@ angular.module('Bastion.auth').service('Authorization', ['CurrentUser', 'Permiss
32
32
  this.denied = function (permissionName, model) {
33
33
  return !this.permitted(permissionName, model);
34
34
  };
35
+
36
+ this.getCurrentUser = function () {
37
+ return CurrentUser;
38
+ };
35
39
  }]);
@@ -13,5 +13,6 @@ BASTION_MODULES = [
13
13
  'Bastion.auth',
14
14
  'Bastion.menu',
15
15
  'Bastion.i18n',
16
- 'Bastion.features'
16
+ 'Bastion.features',
17
+ 'Bastion.routing'
17
18
  ];
@@ -14,7 +14,7 @@
14
14
  //= require "angular-rails-templates"
15
15
 
16
16
  //= require "bastion/bastion.module"
17
- //= require "bastion/bastion-resource.factory"
17
+ //= require "bastion/routing.module.js"
18
18
 
19
19
  //= require "bastion/i18n/i18n.module"
20
20
  //= require "bastion/i18n/translate.service.js"
@@ -6,20 +6,13 @@
6
6
  * Base module that defines the Katello module namespace and includes any thirdparty
7
7
  * modules used by the application.
8
8
  */
9
- angular.module('Bastion', [
10
- 'ui.router',
11
- 'ngResource',
12
- 'Bastion.i18n',
13
- 'Bastion.components'
14
- ]);
9
+ angular.module('Bastion', []);
15
10
 
16
11
  /**
17
12
  * @ngdoc config
18
13
  * @name Bastion.config
19
14
  *
20
15
  * @requires $httpProvider
21
- * @requires $urlRouterProvider
22
- * @requires $locationProvider
23
16
  * @requires $provide
24
17
  * @requires BastionConfig
25
18
  *
@@ -28,57 +21,13 @@ angular.module('Bastion', [
28
21
  * to every request and adding Xs to translated strings.
29
22
  */
30
23
  angular.module('Bastion').config(
31
- ['$httpProvider', '$urlRouterProvider', '$locationProvider', '$provide', 'BastionConfig',
32
- function ($httpProvider, $urlRouterProvider, $locationProvider, $provide, BastionConfig) {
33
- var oldBrowserBastionPath = '/bastion#';
34
-
24
+ ['$httpProvider', '$provide', 'BastionConfig',
25
+ function ($httpProvider, $provide, BastionConfig) {
35
26
  $httpProvider.defaults.headers.common = {
36
27
  Accept: 'application/json, text/plain, version=2; */*',
37
28
  'X-CSRF-TOKEN': angular.element('meta[name=csrf-token]').attr('content')
38
29
  };
39
30
 
40
- $urlRouterProvider.rule(function ($injector, $location) {
41
- var $sniffer = $injector.get('$sniffer'),
42
- $window = $injector.get('$window'),
43
- path = $location.path();
44
-
45
- if (!$sniffer.history) {
46
- $window.location.href = oldBrowserBastionPath + $location.path();
47
- }
48
-
49
- if (/^\/katello($|\/)/.test(path)) {
50
- $window.location.href = $location.url();
51
- $window.location.reload();
52
- }
53
-
54
- // removing trailing slash to prevent endless redirect
55
- if (path[path.length - 1] === '/') {
56
- return path.slice(0, -1);
57
- }
58
- });
59
-
60
- $urlRouterProvider.otherwise(function ($injector, $location) {
61
- var $window = $injector.get('$window'),
62
- $state = $injector.get('$state'),
63
- parentState = $location.path().split('/')[1].replace('_', '-'),
64
- url = $location.absUrl();
65
-
66
- // ensure we don't double encode +s
67
- url = url.replace(/%2B/g, "+");
68
-
69
- // Remove the old browser path if present
70
- url = url.replace(oldBrowserBastionPath, '');
71
-
72
- if ($state.get(parentState)) {
73
- $window.location.href = '/404';
74
- } else {
75
- $window.location.href = url;
76
- }
77
- return $location.path();
78
- });
79
-
80
- $locationProvider.html5Mode({enabled: true, requireBase: false});
81
-
82
31
  $provide.factory('PrefixInterceptor', ['$q', '$templateCache', function ($q, $templateCache) {
83
32
  return {
84
33
  request: function (config) {
@@ -9,6 +9,6 @@
9
9
  * Cross application re-usable components
10
10
  */
11
11
  angular
12
- .module('Bastion.components', []);
12
+ .module('Bastion.components', ['ngResource', 'Bastion.utils']);
13
13
 
14
14
  })();
@@ -3,7 +3,7 @@
3
3
  * @name Bastion.components.directive:currentTasks
4
4
  *
5
5
  * @requires $document
6
- * @requires CurrentUser
6
+ * @requires authorizationService
7
7
  * @requires Task
8
8
  *
9
9
  * @description
@@ -14,8 +14,8 @@
14
14
  <span current-tasks></span>
15
15
  */
16
16
  angular.module('Bastion.components').directive('currentTasks',
17
- ['$document', 'CurrentUser', 'Task',
18
- function ($document, CurrentUser, Task) {
17
+ ['$document', 'authorizationService', 'Task',
18
+ function ($document, authorizationService, Task) {
19
19
 
20
20
  return {
21
21
  restrict: 'A',
@@ -26,7 +26,7 @@ angular.module('Bastion.components').directive('currentTasks',
26
26
  // Hide the current tasks list if the user clicks outside of it
27
27
  var currentTasksMenu = angular.element('#currentTasks');
28
28
  $scope.visible = false;
29
- $scope.currentUser = CurrentUser;
29
+ $scope.currentUser = authorizationService.getCurrentUser();
30
30
  $scope.count = 0;
31
31
 
32
32
  $scope.toggleVisibility = function () {
@@ -48,7 +48,8 @@ angular.module('Bastion.components').directive('currentTasks',
48
48
  });
49
49
  }],
50
50
  link: function (scope) {
51
- Task.registerSearch({ 'active_only': true, 'type': 'user', 'user_id': CurrentUser.id}, scope.updateTasks);
51
+ var searchParams = {'active_only': true, 'type': 'user', 'user_id': authorizationService.getCurrentUser().id};
52
+ Task.registerSearch(searchParams, scope.updateTasks);
52
53
  }
53
54
  };
54
55
  }]);
@@ -6,6 +6,5 @@
6
6
  * Module for internationalization.
7
7
  */
8
8
  angular.module('Bastion.i18n', [
9
- 'gettext',
10
- 'Bastion'
9
+ 'gettext'
11
10
  ]);
@@ -6,6 +6,5 @@
6
6
  * Module for menu related functionality.
7
7
  */
8
8
  angular.module('Bastion.menu', [
9
- 'Bastion',
10
9
  'Bastion.components'
11
10
  ]);
@@ -0,0 +1,81 @@
1
+ angular.module('Bastion.routing', ['ui.router']);
2
+
3
+ (function () {
4
+ 'use strict';
5
+
6
+ /**
7
+ * @ngdoc config
8
+ * @name Bastion.routing.config
9
+ *
10
+ * @requires $urlRouterProvider
11
+ * @requires $locationProvider
12
+ *
13
+ * @description
14
+ * Routing configuration for Bastion.
15
+ */
16
+ function bastionRouting($urlRouterProvider, $locationProvider) {
17
+ var oldBrowserBastionPath = '/bastion#', getRootPath;
18
+
19
+ getRootPath = function (path) {
20
+ var rootPath = null;
21
+
22
+ if (path && angular.isString(path)) {
23
+ rootPath = path.replace('_', '-').split('/')[1];
24
+ }
25
+ return rootPath;
26
+ };
27
+
28
+ $urlRouterProvider.rule(function ($injector, $location) {
29
+ var $sniffer = $injector.get('$sniffer'),
30
+ $window = $injector.get('$window'),
31
+ path = $location.path();
32
+
33
+ if (!$sniffer.history) {
34
+ $window.location.href = oldBrowserBastionPath + $location.path();
35
+ }
36
+
37
+ // removing trailing slash to prevent endless redirect
38
+ if (path[path.length - 1] === '/') {
39
+ return path.slice(0, -1);
40
+ }
41
+ });
42
+
43
+ $urlRouterProvider.otherwise(function ($injector, $location) {
44
+ var $window = $injector.get('$window'),
45
+ $state = $injector.get('$state'),
46
+ rootPath = getRootPath($location.path()),
47
+ url = $location.absUrl(),
48
+ foundParentState;
49
+
50
+ // ensure we don't double encode +s
51
+ url = url.replace(/%2B/g, "+");
52
+
53
+ // Remove the old browser path if present
54
+ url = url.replace(oldBrowserBastionPath, '');
55
+
56
+ if (rootPath) {
57
+ foundParentState = _.find($state.get(), function (state) {
58
+ var found = false;
59
+ if (state.url) {
60
+ found = getRootPath(state.url) === rootPath;
61
+ }
62
+
63
+ return found;
64
+ });
65
+ }
66
+
67
+ if (foundParentState) {
68
+ $window.location.href = '/404';
69
+ } else {
70
+ $window.location.href = url;
71
+ }
72
+ return $location.path();
73
+ });
74
+
75
+ $locationProvider.html5Mode(true);
76
+
77
+ }
78
+
79
+ angular.module('Bastion.routing').config(bastionRouting);
80
+ bastionRouting.$inject = ['$urlRouterProvider', '$locationProvider'];
81
+ })();
@@ -1,18 +1,17 @@
1
1
  /**
2
2
  * @ngdoc factory
3
- * @name Bastion.factory:BastionResource
3
+ * @name Bastion.utils.factory:BastionResource
4
4
  *
5
- * @requires BastionResource
5
+ * @requires $resource
6
6
  *
7
7
  * @description
8
8
  * Base module that defines the Katello module namespace and includes any thirdparty
9
9
  * modules used by the application.
10
10
  */
11
- angular.module('Bastion').factory('BastionResource', ['$resource', function ($resource) {
11
+ angular.module('Bastion.utils').factory('BastionResource', ['$resource', function ($resource) {
12
12
 
13
13
  return function (url, paramDefaults, actions) {
14
14
  var defaultActions;
15
-
16
15
  defaultActions = {
17
16
  queryPaged: {method: 'GET', isArray: false},
18
17
  queryUnpaged: {method: 'GET', isArray: false, params: {'full_result': true}}
@@ -5,4 +5,4 @@
5
5
  * @description
6
6
  * Module for common utilities.
7
7
  */
8
- angular.module('Bastion.utils', ['Bastion', 'uuid4']);
8
+ angular.module('Bastion.utils', ['uuid4', 'ngResource']);
@@ -1,3 +1,7 @@
1
+ <% content_for(:head) do %>
2
+ <base href="/bastion"/>
3
+ <% end %>
4
+
1
5
  <% content_for(:content) do %>
2
6
  <div class="article maincontent bastion" data-no-turbolink="true">
3
7
  <section class="container-fluid">
@@ -16,13 +16,13 @@
16
16
  angular.module('Bastion.features').value('FeatureSettings', angular.fromJson(<%= SETTINGS[:features].nil? ? {} : SETTINGS[:features].to_json.html_safe %>));
17
17
  angular.module('Bastion').value('currentLocale', '<%= I18n.locale %>');
18
18
  angular.module('Bastion').value('CurrentOrganization', "<%= Organization.current.id if Organization.current %>");
19
- angular.module('Bastion').value('Permissions', angular.fromJson('<%= User.current.cached_roles.collect { |role| role.permissions }.flatten.to_json.html_safe %>'));
20
- angular.module('Bastion').value('CurrentUser', {
21
- id: <%= User.current.id %>,
22
- admin: <%= User.current.admin || User.current.usergroups.any? { |group| group.admin } %>
23
- });
24
19
  angular.module('Bastion').value('markActiveMenu', mark_active_menu);
25
20
  angular.module('Bastion').constant('BastionConfig', angular.fromJson('<%= Bastion.config.to_json.html_safe %>'));
21
+ angular.module('Bastion.auth').value('CurrentUser', {
22
+ id: <%= User.current.id %>,
23
+ admin: <%= User.current.admin || User.current.usergroups.any? { |group| group.admin } %>
24
+ });
25
+ angular.module('Bastion.auth').value('Permissions', angular.fromJson('<%= User.current.cached_roles.collect { |role| role.permissions }.flatten.to_json.html_safe %>'));
26
26
  </script>
27
27
  <% Bastion.plugins.each do |name, plugin| %>
28
28
  <%= javascript_include_tag(plugin[:javascript]) %>
data/grunt/karma.js CHANGED
@@ -33,7 +33,7 @@ module.exports = {
33
33
 
34
34
  basePath + 'app/assets/javascripts/bastion/bastion-bootstrap.js',
35
35
  basePath + 'app/assets/javascripts/bastion/bastion.module.js',
36
- basePath + 'app/assets/javascripts/bastion/bastion-resource.factory.js',
36
+ basePath + 'app/assets/javascripts/bastion/routing.module.js',
37
37
  basePath + 'app/assets/javascripts/bastion/i18n/i18n.module.js',
38
38
  basePath + 'app/assets/javascripts/bastion/i18n/*.js',
39
39
  basePath + 'app/assets/javascripts/bastion/auth/auth.module.js',
@@ -1,3 +1,3 @@
1
1
  module Bastion
2
- VERSION = "3.3.1"
2
+ VERSION = "3.3.2"
3
3
  end
@@ -47,4 +47,8 @@ describe('Service:Authorization', function() {
47
47
  });
48
48
  });
49
49
  });
50
+
51
+ it("returns the current user", function () {
52
+ expect(Authorization.getCurrentUser()).toBe(CurrentUser);
53
+ });
50
54
  });
@@ -1,13 +1,13 @@
1
1
  angular.module('Bastion').value('currentLocale', 'Here');
2
2
  angular.module('Bastion').value('CurrentOrganization', "ACME");
3
- angular.module('Bastion').value('CurrentUser', {id: "User"});
4
- angular.module('Bastion').value('Permissions', []);
5
3
  angular.module('Bastion').value('Authorization', {});
6
4
  angular.module('Bastion').value('markActiveMenu', function () {});
7
5
  angular.module('Bastion').constant('BastionConfig', {
8
6
  consumerCertRPM: "consumer_cert_rpm",
9
7
  markTranslated: false
10
8
  });
9
+ angular.module('Bastion.auth').value('CurrentUser', {id: "User"});
10
+ angular.module('Bastion.auth').value('Permissions', []);
11
11
 
12
12
  angular.module('templates', []);
13
13
 
@@ -3,7 +3,7 @@ describe('Factory: BstBookmark', function() {
3
3
  bookmarks,
4
4
  BstBookmark;
5
5
 
6
- beforeEach(module('Bastion', 'Bastion.components'));
6
+ beforeEach(module('Bastion.components'));
7
7
 
8
8
  beforeEach(module(function() {
9
9
  bookmarks = {
@@ -0,0 +1,70 @@
1
+ describe('config: Bastion.routing', function () {
2
+ var $rootScope, $location, $sniffer, $window, $state;
3
+
4
+ function goTo(url) {
5
+ $location.url(url);
6
+ $rootScope.$digest();
7
+ }
8
+
9
+ beforeEach(module('Bastion.routing'));
10
+
11
+ beforeEach(module(function ($provide) {
12
+ $sniffer = {
13
+ history: true
14
+ };
15
+
16
+ $window = {
17
+ location: {
18
+ href: '',
19
+ reload: function () {}
20
+ }
21
+ };
22
+
23
+ $provide.value('$sniffer', $sniffer);
24
+ $provide.value('$window', $window);
25
+ }));
26
+
27
+ beforeEach(inject(function (_$rootScope_, _$state_, _$location_) {
28
+ $rootScope = _$rootScope_;
29
+ $state = _$state_;
30
+ $location = _$location_;
31
+ }));
32
+
33
+ describe("provides a rule that", function () {
34
+ it("removes any trailing slashes from the url", function () {
35
+ goTo('/state///');
36
+ expect($window.location.href).toBe('http://server/state');
37
+ });
38
+ });
39
+
40
+ describe("provides an otherwise method that", function () {
41
+ it('replaces encoded + characters with their decoded counterpart', function () {
42
+ goTo('/some-state%2B%2B');
43
+ expect($window.location.href).toBe('http://server/some-state++');
44
+ });
45
+
46
+ it('removes the old browser compatibility path', function () {
47
+ spyOn($location, 'absUrl').and.returnValue('http://server/bastion#/some-state');
48
+ goTo('/some-state');
49
+ expect($window.location.href).toBe('http://server/some-state');
50
+ });
51
+
52
+ describe("handles undefined states by", function () {
53
+ beforeEach(function () {
54
+
55
+ });
56
+
57
+ it("redirecting to a 404 page if the parent state is found", function () {
58
+ spyOn($state, 'get').and.returnValue([{url: '/found-state'}]);
59
+ goTo('/found_state/does_not_exist');
60
+ expect($window.location.href).toBe('/404');
61
+ });
62
+
63
+ it("redirecting to the url if no parent state is found", function () {
64
+ goTo('/non-parent');
65
+ expect($window.location.href).toBe('http://server/non-parent');
66
+ });
67
+
68
+ });
69
+ });
70
+ });
@@ -1,7 +1,7 @@
1
1
  describe('Factory: BastionResource', function() {
2
2
  var resource;
3
3
 
4
- beforeEach(module('Bastion'));
4
+ beforeEach(module('Bastion.utils'));
5
5
 
6
6
  beforeEach(inject(function($injector) {
7
7
  resource = $injector.get('BastionResource');
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bastion
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric D Helms
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-09 00:00:00.000000000 Z
12
+ date: 2016-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: angular-rails-templates
@@ -57,7 +57,6 @@ files:
57
57
  - app/assets/javascripts/bastion/auth/auth.module.js
58
58
  - app/assets/javascripts/bastion/auth/authorization.service.js
59
59
  - app/assets/javascripts/bastion/bastion-bootstrap.js
60
- - app/assets/javascripts/bastion/bastion-resource.factory.js
61
60
  - app/assets/javascripts/bastion/bastion.js
62
61
  - app/assets/javascripts/bastion/bastion.module.js
63
62
  - app/assets/javascripts/bastion/components/bst-alert.directive.js
@@ -144,6 +143,8 @@ files:
144
143
  - app/assets/javascripts/bastion/layouts/select-all-results.html
145
144
  - app/assets/javascripts/bastion/menu/menu-expander.service.js
146
145
  - app/assets/javascripts/bastion/menu/menu.module.js
146
+ - app/assets/javascripts/bastion/routing.module.js
147
+ - app/assets/javascripts/bastion/utils/bastion-resource.factory.js
147
148
  - app/assets/javascripts/bastion/utils/form-utils.service.js
148
149
  - app/assets/javascripts/bastion/utils/urlencode.filter.js
149
150
  - app/assets/javascripts/bastion/utils/utils.module.js
@@ -178,7 +179,6 @@ files:
178
179
  - lib/bastion/version.rb
179
180
  - package.json
180
181
  - test/auth/authorization.service.test.js
181
- - test/bastion/bastion-resource.factory.test.js
182
182
  - test/bastion/test-constants.js
183
183
  - test/components/bst-alert.directive.test.js
184
184
  - test/components/bst-alerts.directive.test.js
@@ -210,7 +210,9 @@ files:
210
210
  - test/features/feature-flag.service.test.js
211
211
  - test/i18n/translate.service.test.js
212
212
  - test/menu/menu-expander.service.test.js
213
+ - test/routing.module.test.js
213
214
  - test/test-mocks.module.js
215
+ - test/utils/bastion-resource.factory.test.js
214
216
  - test/utils/form-utils.service.test.js
215
217
  - test/utils/urlencode.filter.test.js
216
218
  - vendor/assets/javascripts/bastion/angular-animate/angular-animate.js
@@ -1031,11 +1033,12 @@ test_files:
1031
1033
  - test/components/global-notification.service.test.js
1032
1034
  - test/components/bst-edit.directive.test.js
1033
1035
  - test/components/bst-modal.directive.test.js
1036
+ - test/routing.module.test.js
1034
1037
  - test/test-mocks.module.js
1035
1038
  - test/menu/menu-expander.service.test.js
1036
1039
  - test/i18n/translate.service.test.js
1037
1040
  - test/bastion/test-constants.js
1038
- - test/bastion/bastion-resource.factory.test.js
1039
1041
  - test/utils/form-utils.service.test.js
1042
+ - test/utils/bastion-resource.factory.test.js
1040
1043
  - test/utils/urlencode.filter.test.js
1041
1044
  has_rdoc: