Skip to content

Commit

Permalink
Maintain separate user lists for each environment (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
bess authored Apr 8, 2024
1 parent c0a507b commit 379b713
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class User < ApplicationRecord

has_many :user_jobs, dependent: :destroy

USER_REGISTRATION_LIST = Rails.root.join("data", "user_registration_list.csv")
USER_REGISTRATION_LIST = Rails.root.join("data", "user_registration_list_#{Rails.env}.csv")

def self.from_cas(access_token)
user = User.find_by(provider: access_token.provider, uid: access_token.uid)
Expand Down Expand Up @@ -70,36 +70,50 @@ def terminate_mediaflux_session
@mediaflux_session = nil
end

# Initialize the name values from the CAS information.
# Our name fields do not match their name fields, so we need to translate.
def initialize_name_values(extra_cas_info)
self.given_name = extra_cas_info.givenname
self.family_name = extra_cas_info.sn
self.display_name = extra_cas_info.pudisplayname
end

# Return the display name if it exists, otherwise return the uid
# @return [String]
def display_name_safe
return uid if display_name.blank?

display_name
end

# Is this user eligible to be a data sponsor in this environment?
# @return [Boolean]
def eligible_sponsor?
return true if superuser
super
end

# Is this user eligible to be a data manger in this environment?
# @return [Boolean]
def eligible_manager?
return true if superuser
super
end

# Is this user eligible to be a sysadmin in this environment?
# @return [Boolean]
def eligible_sysadmin?
return true if superuser || sysadmin
end

# Parse the USER_REGISTRATION_LIST csv
# @return [CSV::Table]
def self.csv_data
CSV.parse(File.read(USER_REGISTRATION_LIST), headers: true)
end

# Load the user registration list from the CSV file.
# Select the file that matches the rails environment.
def self.load_registration_list
User.csv_data.each do |line|
user = User.find_by(uid: line["uid"]) || User.new
Expand Down
File renamed without changes.
37 changes: 37 additions & 0 deletions data/user_registration_list_production.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
uid,email,given_name,family_name,display_name,eligible_sponsor,eligible_manager,superuser,sysadmin,DateAdded,AddedBy,Notes
mjc12,,Matt,Chandler,Matt Chandler,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
hb0344,,Halle,Burns,Halle Burns,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
eparham,,Beth,Holtz,Beth Holtz,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
cbentler,,Chuck,Bentler,Chuck Bentler,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
knight,,Robert,Knight,Robert Knight,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
kl37,,Kate,Lynch,Kate Lynch,TRUE,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
hc8719,,Hector,Correa,Hector Correa,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
bs3097,,Bess,Sadler,Bess Sadler,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
cac9,,Carolyn,Cole,Carolyn Cole,,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jrg5,,James,Griffin,James Griffin,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
rl3667,,Robert,Lee-Faison,Robert Lee-Faison,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jh6441,,Jaymee,Hyppolite,Jaymee Hyppolite,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
changgoo,,Chang-Goo,Kim,Chang-Goo Kim,TRUE,TRUE,,,2023-12-05,Matt Chandler,Early Adopter
eostrike,,Eve,Ostriker,Eve Ostriker,TRUE,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
la15,,Lucia,Armillotta,Lucia Armillotta,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
rh1136,,Ronan,Hix,Ronan Hix,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sm4550,,Shaunak,Modak,Shaunak Modak,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
jk11,,Justin,Kim,Justin Kim,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
nlinzer,,Nora,Linzer,Nora Linzer,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sm69,,Sanghyuk,Moon,Sanghyuk Moon,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
lachlanl,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
ikaul,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
woongkim,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
munan,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sswang,,Sam,Wang,Sam Wang,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
mkislin,,Mikhail,Kislin,Mikhail Kislin,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Sam Wang"
jdunkley,,Jo,Dunkley,Jo Dunkley,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
zatkins,,Zach,Atkins,Zach Atkins,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Jo Dunkley"
lboustan,,Leah,Boustan,Leah Boustan,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
aegreen,,Allison,Green,Allison Green,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Leah Boustan"
mm4,,Meredith,Martin,Meredith Martin,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
mnaydan,,Mary,Neyden,Mary Neyden,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
rkoeser,,Rebecca,Koeser,Rebecca Koeser,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
rh6841,,Ryan,Heuser,Ryan Heuser,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
wh4213,,Wouter,Haverals,Wouter Haverals,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
lauret,,Laure,Thompson,Laure Thompson,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
37 changes: 37 additions & 0 deletions data/user_registration_list_qa.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
uid,email,given_name,family_name,display_name,eligible_sponsor,eligible_manager,superuser,sysadmin,DateAdded,AddedBy,Notes
mjc12,,Matt,Chandler,Matt Chandler,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
hb0344,,Halle,Burns,Halle Burns,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
eparham,,Beth,Holtz,Beth Holtz,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
cbentler,,Chuck,Bentler,Chuck Bentler,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
knight,,Robert,Knight,Robert Knight,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
kl37,,Kate,Lynch,Kate Lynch,TRUE,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
hc8719,,Hector,Correa,Hector Correa,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
bs3097,,Bess,Sadler,Bess Sadler,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
cac9,,Carolyn,Cole,Carolyn Cole,,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jrg5,,James,Griffin,James Griffin,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
rl3667,,Robert,Lee-Faison,Robert Lee-Faison,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jh6441,,Jaymee,Hyppolite,Jaymee Hyppolite,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
changgoo,,Chang-Goo,Kim,Chang-Goo Kim,TRUE,TRUE,,,2023-12-05,Matt Chandler,Early Adopter
eostrike,,Eve,Ostriker,Eve Ostriker,TRUE,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
la15,,Lucia,Armillotta,Lucia Armillotta,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
rh1136,,Ronan,Hix,Ronan Hix,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sm4550,,Shaunak,Modak,Shaunak Modak,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
jk11,,Justin,Kim,Justin Kim,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
nlinzer,,Nora,Linzer,Nora Linzer,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sm69,,Sanghyuk,Moon,Sanghyuk Moon,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
lachlanl,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
ikaul,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
woongkim,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
munan,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sswang,,Sam,Wang,Sam Wang,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
mkislin,,Mikhail,Kislin,Mikhail Kislin,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Sam Wang"
jdunkley,,Jo,Dunkley,Jo Dunkley,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
zatkins,,Zach,Atkins,Zach Atkins,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Jo Dunkley"
lboustan,,Leah,Boustan,Leah Boustan,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
aegreen,,Allison,Green,Allison Green,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Leah Boustan"
mm4,,Meredith,Martin,Meredith Martin,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
mnaydan,,Mary,Neyden,Mary Neyden,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
rkoeser,,Rebecca,Koeser,Rebecca Koeser,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
rh6841,,Ryan,Heuser,Ryan Heuser,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
wh4213,,Wouter,Haverals,Wouter Haverals,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
lauret,,Laure,Thompson,Laure Thompson,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
14 changes: 14 additions & 0 deletions data/user_registration_list_staging.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uid,email,given_name,family_name,display_name,eligible_sponsor,eligible_manager,superuser,sysadmin,DateAdded,AddedBy,Notes
mjc12,,Matt,Chandler,Matt Chandler,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
hb0344,,Halle,Burns,Halle Burns,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
eparham,,Beth,Holtz,Beth Holtz,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
cbentler,,Chuck,Bentler,Chuck Bentler,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
knight,,Robert,Knight,Robert Knight,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
kl37,,Kate,Lynch,Kate Lynch,TRUE,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
hc8719,,Hector,Correa,Hector Correa,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
bs3097,,Bess,Sadler,Bess Sadler,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
cac9,,Carolyn,Cole,Carolyn Cole,,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jrg5,,James,Griffin,James Griffin,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
rl3667,,Robert,Lee-Faison,Robert Lee-Faison,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jh6441,,Jaymee,Hyppolite,Jaymee Hyppolite,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
sw5452,[email protected],Sean,Warren,Sean Warren,,,TRUE,,2023-03-28,Bess Sadler,TigerData Staff
37 changes: 37 additions & 0 deletions data/user_registration_list_test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
uid,email,given_name,family_name,display_name,eligible_sponsor,eligible_manager,superuser,sysadmin,DateAdded,AddedBy,Notes
mjc12,,Matt,Chandler,Matt Chandler,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
hb0344,,Halle,Burns,Halle Burns,TRUE,TRUE,,,2023-12-05,Matt Chandler,TigerData Staff
eparham,,Beth,Holtz,Beth Holtz,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
cbentler,,Chuck,Bentler,Chuck Bentler,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
knight,,Robert,Knight,Robert Knight,TRUE,TRUE,,TRUE,2023-12-05,Matt Chandler,TigerData Staff
kl37,,Kate,Lynch,Kate Lynch,TRUE,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
hc8719,,Hector,Correa,Hector Correa,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
bs3097,,Bess,Sadler,Bess Sadler,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
cac9,,Carolyn,Cole,Carolyn Cole,,TRUE,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jrg5,,James,Griffin,James Griffin,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
rl3667,,Robert,Lee-Faison,Robert Lee-Faison,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
jh6441,,Jaymee,Hyppolite,Jaymee Hyppolite,,,TRUE,,2023-12-05,Matt Chandler,TigerData Staff
changgoo,,Chang-Goo,Kim,Chang-Goo Kim,TRUE,TRUE,,,2023-12-05,Matt Chandler,Early Adopter
eostrike,,Eve,Ostriker,Eve Ostriker,TRUE,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
la15,,Lucia,Armillotta,Lucia Armillotta,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
rh1136,,Ronan,Hix,Ronan Hix,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sm4550,,Shaunak,Modak,Shaunak Modak,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
jk11,,Justin,Kim,Justin Kim,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
nlinzer,,Nora,Linzer,Nora Linzer,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sm69,,Sanghyuk,Moon,Sanghyuk Moon,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
lachlanl,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
ikaul,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
woongkim,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
munan,,,,,,,,,2023-12-05,Matt Chandler,"Early Adopter, under Chang-Goo Kim"
sswang,,Sam,Wang,Sam Wang,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
mkislin,,Mikhail,Kislin,Mikhail Kislin,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Sam Wang"
jdunkley,,Jo,Dunkley,Jo Dunkley,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
zatkins,,Zach,Atkins,Zach Atkins,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Jo Dunkley"
lboustan,,Leah,Boustan,Leah Boustan,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
aegreen,,Allison,Green,Allison Green,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Leah Boustan"
mm4,,Meredith,Martin,Meredith Martin,TRUE,,,,2024-02-05,Matt Chandler,Early Adopter
mnaydan,,Mary,Neyden,Mary Neyden,,TRUE,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
rkoeser,,Rebecca,Koeser,Rebecca Koeser,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
rh6841,,Ryan,Heuser,Ryan Heuser,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
wh4213,,Wouter,Haverals,Wouter Haverals,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
lauret,,Laure,Thompson,Laure Thompson,,,,,2024-02-05,Matt Chandler,"Early Adopter, under Meredith Martin"
18 changes: 18 additions & 0 deletions spec/support/system_specs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by(:rack_test)
end

config.before(:each, type: :system, js: true) do
if ENV["RUN_IN_BROWSER"]
driven_by(:selenium)
else
driven_by(:selenium_headless)
end
end
config.before(:each, type: :system, js: true, in_browser: true) do
driven_by(:selenium)
end
end

0 comments on commit 379b713

Please sign in to comment.