Skip to content

Commit 2c1df33

Browse files
authored
Merge pull request #893 from portagenetwork/integration
Merge Changes For Upcoming Release `4.1.1+portage-4.2.0`
2 parents 44b2ed9 + 3f63a66 commit 2c1df33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1775
-300
lines changed

.github/workflows/mysql.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ jobs:
7373
7474
# Run the time consuming integration tests (using Chrome headless browser)
7575
- name: 'Run Rspec Integration Tests'
76-
run: bundle exec rspec spec/features/
76+
run: |
77+
bundle exec rspec spec/features/
78+
bundle exec rspec spec/integration/

.github/workflows/postgres.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@ jobs:
9595
9696
# Run the time consuming integration tests (using Chrome headless browser)
9797
- name: 'Run Integration Tests'
98-
run: bundle exec rspec spec/features/
98+
run: |
99+
bundle exec rspec spec/features/
100+
bundle exec rspec spec/integration/

.github/workflows/ruby.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ jobs:
9191
bin/rails assets:precompile
9292
9393
- name: Run tests
94-
run: bundle exec rake spec
94+
run: bundle exec rspec

CHANGELOG.md

+32
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
22

33
## [4.1.1+portage-4.1.3] - 2024-08-08
44

5+
### Added
6+
7+
- Add Rake Upgrade Task For `4.1.1+portage-4.2.0` [#892](https://github.com/portagenetwork/roadmap/pull/892)
8+
9+
- Test cases for CILogon(openid_connection) changes in Omniauth controller - [#869](https://github.com/portagenetwork/roadmap/pull/869/)
10+
11+
- Implemented openid_connection SSO with CILogon [#872](https://github.com/portagenetwork/roadmap/pull/872)
12+
13+
- Create GET "/api/ca_dashboard/stats" endpoint to fetch Plan, User, and Org-related statistics [#852](https://github.com/portagenetwork/roadmap/pull/852)
14+
15+
- Added SSO changes updates to the About and Help pages. [#882](https://github.com/portagenetwork/roadmap/pull/882)
16+
17+
### Changed
18+
19+
- Update Favicons and Associated HTML Code [#873](https://github.com/portagenetwork/roadmap/pull/873)
20+
21+
- Drop Sessions Table and Delete `lib/tasks/sessions.rake` [#859](https://github.com/portagenetwork/roadmap/pull/859)
22+
23+
- Optimise Load Time of "Edit Profile" Page [#883](https://github.com/portagenetwork/roadmap/pull/883)
24+
25+
- Update ruby workflow command for executing tests [#896](https://github.com/portagenetwork/roadmap/pull/896)
26+
27+
### Fixed
28+
29+
- Fix triggering and title of autosent email when a user's admin privileges are changed [#858](https://github.com/portagenetwork/roadmap/pull/858)
30+
31+
- Fix flaky tests / Optimize Checking Of `plan.title` Within `spec/features/plans/exports_spec.rb` [#871](https://github.com/portagenetwork/roadmap/pull/871)
32+
33+
- Patch to Put Back ORCID Linking Functionality [#891](https://github.com/portagenetwork/roadmap/pull/891)
34+
35+
## [4.1.1+portage-4.1.3] - 2024-08-08
36+
537
### Changed
638

739
- Bump rexml from 3.2.8 to 3.3.3 [#839](https://github.com/portagenetwork/roadmap/pull/839)

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ gem 'omniauth-orcid'
107107
# https://nvd.nist.gov/vuln/detail/CVE-2015-9284
108108
gem 'omniauth-rails_csrf_protection'
109109

110+
# This gem provides cilogon support with devise login authentication
111+
gem 'omniauth_openid_connect'
112+
110113
# A ruby implementation of the RFC 7519 OAuth JSON Web Token (JWT) standard.
111114
gem 'jwt'
112115

Gemfile.lock

+51
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ GEM
7575
zeitwerk (~> 2.3)
7676
addressable (2.8.6)
7777
public_suffix (>= 2.0.2, < 6.0)
78+
aes_key_wrap (1.1.0)
7879
annotate (3.2.0)
7980
activerecord (>= 3.2, < 8.0)
8081
rake (>= 10.4, < 14.0)
8182
annotate_gem (0.0.14)
8283
bundler (>= 1.1)
8384
api-pagination (5.0.0)
8485
ast (2.4.2)
86+
attr_required (1.0.2)
8587
autoprefixer-rails (10.4.16.0)
8688
execjs (~> 2)
8789
base64 (0.1.1)
@@ -91,6 +93,7 @@ GEM
9193
rack (>= 0.9.0)
9294
rouge (>= 1.0.0)
9395
bigdecimal (3.1.8)
96+
bindata (2.5.0)
9497
bindex (0.8.1)
9598
binding_of_caller (1.0.1)
9699
debug_inspector (>= 1.2.0)
@@ -179,6 +182,8 @@ GEM
179182
fog-aws
180183
ecma-re-validator (0.4.0)
181184
regexp_parser (~> 2.2)
185+
email_validator (2.2.4)
186+
activemodel
182187
erubi (1.13.0)
183188
excon (0.104.0)
184189
execjs (2.9.1)
@@ -191,6 +196,8 @@ GEM
191196
i18n (>= 1.8.11, < 2)
192197
faraday (2.9.0)
193198
faraday-net_http (>= 2.0, < 3.2)
199+
faraday-follow_redirects (0.3.0)
200+
faraday (>= 1, < 3)
194201
faraday-http-cache (2.5.1)
195202
faraday (>= 0.8)
196203
faraday-net_http (3.1.0)
@@ -257,6 +264,13 @@ GEM
257264
jsbundling-rails (1.3.0)
258265
railties (>= 6.0.0)
259266
json (2.7.2)
267+
json-jwt (1.16.6)
268+
activesupport (>= 4.2)
269+
aes_key_wrap
270+
base64
271+
bindata
272+
faraday (~> 2.0)
273+
faraday-follow_redirects
260274
json_schemer (0.2.25)
261275
ecma-re-validator (~> 0.3)
262276
hana (~> 1.3)
@@ -362,7 +376,23 @@ GEM
362376
omniauth (~> 2.0)
363377
omniauth-shibboleth (1.3.0)
364378
omniauth (>= 1.0.0)
379+
omniauth_openid_connect (0.7.1)
380+
omniauth (>= 1.9, < 3)
381+
openid_connect (~> 2.2)
365382
open4 (1.3.4)
383+
openid_connect (2.3.0)
384+
activemodel
385+
attr_required (>= 1.0.0)
386+
email_validator
387+
faraday (~> 2.0)
388+
faraday-follow_redirects
389+
json-jwt (>= 1.16)
390+
mail
391+
rack-oauth2 (~> 2.2)
392+
swd (~> 2.0)
393+
tzinfo
394+
validate_url
395+
webfinger (~> 2.0)
366396
options (2.3.2)
367397
orm_adapter (0.5.0)
368398
parallel (1.24.0)
@@ -392,6 +422,13 @@ GEM
392422
rack (>= 1.0, < 4)
393423
rack-mini-profiler (3.3.1)
394424
rack (>= 1.2.0)
425+
rack-oauth2 (2.2.1)
426+
activesupport
427+
attr_required
428+
faraday (~> 2.0)
429+
faraday-follow_redirects
430+
json-jwt (>= 1.11.0)
431+
rack (>= 2.1.0)
395432
rack-protection (3.2.0)
396433
base64 (>= 0.1.0)
397434
rack (~> 2.2, >= 2.2.4)
@@ -520,6 +557,11 @@ GEM
520557
activesupport (>= 5.2)
521558
sprockets (>= 3.0.0)
522559
strscan (3.1.0)
560+
swd (2.0.3)
561+
activesupport (>= 3)
562+
attr_required (>= 0.0.5)
563+
faraday (~> 2.0)
564+
faraday-follow_redirects
523565
syslog-logger (1.6.8)
524566
terminal-table (3.0.2)
525567
unicode-display_width (>= 1.1.1, < 3)
@@ -540,6 +582,9 @@ GEM
540582
uniform_notifier (1.16.0)
541583
uri (0.13.0)
542584
uri_template (0.7.0)
585+
validate_url (1.0.15)
586+
activemodel (>= 3.0.0)
587+
public_suffix
543588
version_gem (1.1.3)
544589
warden (1.2.9)
545590
rack (>= 2.0.9)
@@ -548,6 +593,10 @@ GEM
548593
activemodel (>= 6.0.0)
549594
bindex (>= 0.4.0)
550595
railties (>= 6.0.0)
596+
webfinger (2.1.3)
597+
activesupport
598+
faraday (~> 2.0)
599+
faraday-follow_redirects
551600
webmock (3.23.1)
552601
addressable (>= 2.8.0)
553602
crack (>= 0.3.2)
@@ -569,6 +618,7 @@ GEM
569618

570619
PLATFORMS
571620
arm64-darwin-21
621+
arm64-darwin-22
572622
x86_64-linux
573623

574624
DEPENDENCIES
@@ -616,6 +666,7 @@ DEPENDENCIES
616666
omniauth-orcid
617667
omniauth-rails_csrf_protection
618668
omniauth-shibboleth
669+
omniauth_openid_connect
619670
parallel
620671
pg
621672
progress_bar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# frozen_string_literal: true
2+
3+
module Api
4+
module CaDashboard
5+
# Handles CRUD operations for "/api/ca_dashboard/stats"
6+
class StatsController < Api::V1::BaseApiController
7+
# Allow public access / bypass JWT authentication via "POST /api/v1/authenticate"
8+
skip_before_action :authorize_request, only: [:index]
9+
10+
# GET /api/ca_dashboard/stats
11+
def index
12+
base_hash = {
13+
'plans' => Plan.all,
14+
'orgs' => Org.where(managed: true).all,
15+
'users' => User.all
16+
}
17+
@totals = {
18+
'all_time' => all_time_counts(base_hash),
19+
'last_30_days' => last_30_days_counts(base_hash)
20+
}
21+
begin
22+
@totals['custom_range'] = custom_range_counts(base_hash) if date_params_present?
23+
render 'api/ca_dashboard/stats/index', status: :ok
24+
rescue ArgumentError
25+
error_msg = _('Invalid date format. please use YYYY-MM-DD when supplying `start` or `end` params.')
26+
render_error(errors: [error_msg], status: :bad_request)
27+
end
28+
end
29+
30+
private
31+
32+
def all_time_counts(base_hash)
33+
base_hash.transform_values(&:count)
34+
end
35+
36+
def last_30_days_counts(base_hash)
37+
base_hash.transform_values do |scope|
38+
scope.where('created_at >= ?', 30.days.ago).count
39+
end
40+
end
41+
42+
def custom_range_counts(base_hash)
43+
start_date = parse_date(params[:start])
44+
end_date = parse_date(params[:end])
45+
base_hash.transform_values do |scope|
46+
scope.where(created_at: start_date..end_date).count
47+
end
48+
end
49+
50+
def date_params_present?
51+
params[:start].present? || params[:end].present?
52+
end
53+
54+
def parse_date(date_string)
55+
Date.strptime(date_string, '%Y-%m-%d') if date_string.present?
56+
end
57+
end
58+
end
59+
end

app/controllers/orgs_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def shibboleth_ds_passthru
151151

152152
end
153153
end
154+
154155
# rubocop:enable Metrics/AbcSize
155156

156157
# POST /orgs (via AJAX from Org Typeaheads ... see below for specific pages)

app/controllers/registrations_controller.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ def edit
88
@user = current_user
99
@prefs = @user.get_preferences(:email)
1010
@languages = Language.sorted_by_abbreviation
11-
@orgs = Org.order('name')
12-
@other_organisations = Org.where(is_other: true).pluck(:id)
11+
@orgs = Org.includes(identifiers: :identifier_scheme).order('name')
1312
@identifier_schemes = IdentifierScheme.for_users.order(:name)
1413
@default_org = current_user.org
1514

@@ -138,9 +137,8 @@ def create
138137
def update
139138
if user_signed_in?
140139
@prefs = @user.get_preferences(:email)
141-
@orgs = Org.order('name')
140+
@orgs = Org.includes(identifiers: :identifier_scheme).order('name')
142141
@default_org = current_user.org
143-
@other_organisations = Org.where(is_other: true).pluck(:id)
144142
@identifier_schemes = IdentifierScheme.for_users.order(:name)
145143
@languages = Language.sorted_by_abbreviation
146144
if params[:skip_personal_details] == 'true'
@@ -254,7 +252,7 @@ def do_update(require_password = true, confirm = false)
254252

255253
else
256254
flash[:alert] = message.blank? ? failure_message(current_user, _('save')) : message
257-
@orgs = Org.order('name')
255+
@orgs = Org.includes(identifiers: :identifier_scheme).order('name')
258256
render 'edit'
259257
end
260258
end

0 commit comments

Comments
 (0)