openstax_accounts 7.13.0 → 8.1.1

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.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/openstax/accounts/application_controller.rb +1 -1
  3. data/app/controllers/openstax/accounts/dev/accounts_controller.rb +1 -1
  4. data/app/controllers/openstax/accounts/dev/base_controller.rb +1 -1
  5. data/app/controllers/openstax/accounts/sessions_controller.rb +7 -8
  6. data/app/handlers/openstax/accounts/sessions_callback.rb +17 -37
  7. data/app/models/openstax/accounts/account.rb +33 -1
  8. data/app/models/openstax/accounts/group.rb +12 -8
  9. data/app/models/openstax/accounts/group_nesting.rb +8 -7
  10. data/app/representers/openstax/accounts/api/v1/unclaimed_account_representer.rb +1 -7
  11. data/app/routines/openstax/accounts/find_or_create_account.rb +9 -9
  12. data/app/routines/openstax/accounts/find_or_create_from_sso.rb +23 -0
  13. data/app/routines/openstax/accounts/sync_accounts.rb +1 -6
  14. data/config/routes.rb +11 -11
  15. data/db/migrate/0_create_openstax_accounts_accounts.rb +1 -1
  16. data/db/migrate/10_assign_missing_uuids_for_local_accounts.rb +2 -2
  17. data/db/migrate/11_add_support_identifier_to_accounts_accounts.rb +1 -1
  18. data/db/migrate/12_add_is_test_to_accounts_accounts.rb +1 -1
  19. data/db/migrate/13_add_school_type_to_accounts_accounts.rb +1 -1
  20. data/db/migrate/1_create_openstax_accounts_groups.rb +1 -1
  21. data/db/migrate/2_create_openstax_accounts_group_members.rb +1 -1
  22. data/db/migrate/3_create_openstax_accounts_group_owners.rb +1 -1
  23. data/db/migrate/4_create_openstax_accounts_group_nestings.rb +1 -1
  24. data/db/migrate/5_add_faculty_status_to_accounts_accounts.rb +1 -1
  25. data/db/migrate/6_add_salesforce_contact_id_to_accounts_accounts.rb +1 -1
  26. data/db/migrate/7_change_accounts_openstax_uid_to_be_nullable.rb +1 -1
  27. data/db/migrate/8_change_accounts_username_to_be_nullable.rb +1 -1
  28. data/db/migrate/9_add_uuid_and_role_to_accounts_accounts.rb +1 -1
  29. data/lib/omniauth/strategies/openstax.rb +6 -23
  30. data/lib/openstax/accounts/configuration.rb +16 -0
  31. data/lib/openstax/accounts/current_user_manager.rb +20 -0
  32. data/lib/openstax/accounts/has_many_through_groups/active_record/base.rb +5 -5
  33. data/lib/openstax/accounts/sso.rb +61 -0
  34. data/lib/openstax/accounts/version.rb +1 -1
  35. data/lib/openstax_accounts.rb +6 -7
  36. data/lib/tasks/sync.rake +3 -3
  37. data/spec/factories/openstax_accounts_account.rb +1 -1
  38. data/spec/factories/openstax_accounts_group.rb +3 -3
  39. data/spec/factories/openstax_accounts_group_member.rb +1 -1
  40. data/spec/factories/openstax_accounts_group_nesting.rb +1 -1
  41. data/spec/factories/openstax_accounts_group_owner.rb +1 -1
  42. metadata +34 -212
  43. data/Rakefile +0 -22
  44. data/spec/cassettes/OpenStax_Accounts_FindOrCreateAccount/can_create_users.yml +0 -303
  45. data/spec/controllers/openstax/accounts/dev/accounts_controller_spec.rb +0 -27
  46. data/spec/controllers/openstax/accounts/forwards_params_spec.rb +0 -75
  47. data/spec/controllers/openstax/accounts/sessions_controller_spec.rb +0 -71
  48. data/spec/controllers/openstax/accounts/uses_this_engine_controller_spec.rb +0 -22
  49. data/spec/dummy/README.md +0 -1
  50. data/spec/dummy/Rakefile +0 -7
  51. data/spec/dummy/app/access_policies/account_access_policy.rb +0 -11
  52. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  53. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  54. data/spec/dummy/app/controllers/api/application_groups_controller.rb +0 -11
  55. data/spec/dummy/app/controllers/api/application_users_controller.rb +0 -15
  56. data/spec/dummy/app/controllers/api/dummy_controller.rb +0 -12
  57. data/spec/dummy/app/controllers/api/group_members_controller.rb +0 -11
  58. data/spec/dummy/app/controllers/api/group_nestings_controller.rb +0 -11
  59. data/spec/dummy/app/controllers/api/group_owners_controller.rb +0 -11
  60. data/spec/dummy/app/controllers/api/groups_controller.rb +0 -15
  61. data/spec/dummy/app/controllers/api/users_controller.rb +0 -15
  62. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  63. data/spec/dummy/app/controllers/oauth_controller.rb +0 -10
  64. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  65. data/spec/dummy/app/models/anonymous_user.rb +0 -48
  66. data/spec/dummy/app/models/ownership.rb +0 -7
  67. data/spec/dummy/app/models/user.rb +0 -29
  68. data/spec/dummy/config.ru +0 -5
  69. data/spec/dummy/config/application.rb +0 -23
  70. data/spec/dummy/config/boot.rb +0 -5
  71. data/spec/dummy/config/database.yml +0 -15
  72. data/spec/dummy/config/environment.rb +0 -5
  73. data/spec/dummy/config/environments/development.rb +0 -40
  74. data/spec/dummy/config/environments/production.rb +0 -82
  75. data/spec/dummy/config/environments/test.rb +0 -39
  76. data/spec/dummy/config/initializers/access_policies.rb +0 -1
  77. data/spec/dummy/config/initializers/assets.rb +0 -8
  78. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  79. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  80. data/spec/dummy/config/initializers/doorkeeper.rb +0 -75
  81. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  82. data/spec/dummy/config/initializers/inflections.rb +0 -16
  83. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  84. data/spec/dummy/config/initializers/openstax_accounts.rb +0 -14
  85. data/spec/dummy/config/initializers/session_store.rb +0 -3
  86. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  87. data/spec/dummy/config/locales/en.yml +0 -5
  88. data/spec/dummy/config/routes.rb +0 -45
  89. data/spec/dummy/config/secrets.yml +0 -8
  90. data/spec/dummy/db/development.sqlite3 +0 -0
  91. data/spec/dummy/db/migrate/1000_create_users.rb +0 -11
  92. data/spec/dummy/db/migrate/1001_create_ownerships.rb +0 -11
  93. data/spec/dummy/db/schema.rb +0 -113
  94. data/spec/dummy/db/test.sqlite3 +0 -0
  95. data/spec/dummy/log/development.log +0 -5137
  96. data/spec/dummy/log/test.log +0 -162651
  97. data/spec/dummy/public/404.html +0 -26
  98. data/spec/dummy/public/422.html +0 -26
  99. data/spec/dummy/public/500.html +0 -25
  100. data/spec/dummy/public/favicon.ico +0 -0
  101. data/spec/dummy/script/rails +0 -6
  102. data/spec/handlers/openstax/accounts/accounts_search_spec.rb +0 -63
  103. data/spec/handlers/openstax/accounts/dev/accounts_search_spec.rb +0 -55
  104. data/spec/handlers/openstax/accounts/sessions_callback_spec.rb +0 -119
  105. data/spec/lib/openstax/accounts/api_spec.rb +0 -212
  106. data/spec/lib/openstax/accounts/configuration_spec.rb +0 -39
  107. data/spec/lib/openstax/accounts/current_user_manager_spec.rb +0 -157
  108. data/spec/lib/openstax/accounts/has_many_through_groups/active_record/base_spec.rb +0 -57
  109. data/spec/models/openstax/accounts/account_spec.rb +0 -114
  110. data/spec/models/openstax/accounts/anonymous_account_spec.rb +0 -9
  111. data/spec/models/openstax/accounts/group_spec.rb +0 -51
  112. data/spec/routines/openstax/accounts/create_group_spec.rb +0 -32
  113. data/spec/routines/openstax/accounts/find_or_create_account_spec.rb +0 -76
  114. data/spec/routines/openstax/accounts/search_accounts_shared_examples.rb +0 -160
  115. data/spec/routines/openstax/accounts/search_accounts_spec.rb +0 -6
  116. data/spec/routines/openstax/accounts/search_local_accounts_spec.rb +0 -6
  117. data/spec/routines/openstax/accounts/sync_accounts_spec.rb +0 -101
  118. data/spec/routines/openstax/accounts/sync_groups_spec.rb +0 -143
  119. data/spec/spec_helper.rb +0 -109
  120. data/spec/vcr_helper.rb +0 -14
data/spec/spec_helper.rb DELETED
@@ -1,109 +0,0 @@
1
- ENV['RAILS_ENV'] ||= 'test'
2
-
3
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
-
5
- require 'rspec/rails'
6
- require 'factory_bot_rails'
7
- require 'shoulda-matchers'
8
-
9
- Rails.backtrace_cleaner.remove_silencers!
10
-
11
- ActiveRecord::Migration.maintain_test_schema!
12
-
13
- # Requires supporting ruby files with custom matchers and macros, etc,
14
- # in spec/support/ and its subdirectories.
15
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
16
-
17
- RSpec.configure do |config|
18
- # ## Mock Framework
19
- #
20
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
21
- #
22
- # config.mock_with :mocha
23
- # config.mock_with :flexmock
24
- # config.mock_with :rr
25
-
26
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
27
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
28
-
29
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
30
- # examples within a transaction, remove the following line or assign false
31
- # instead of true.
32
- config.use_transactional_fixtures = true
33
-
34
- # If true, the base class of anonymous controllers will be inferred
35
- # automatically. This will be the default behavior in future versions of
36
- # rspec-rails.
37
- config.infer_base_class_for_anonymous_controllers = false
38
-
39
- # Run specs in random order to surface order dependencies. If you find an
40
- # order dependency and want to debug it, you can fix the order by providing
41
- # the seed, which is printed after each run.
42
- # --seed 1234
43
- config.order = :random
44
- end
45
-
46
- Shoulda::Matchers.configure do |config|
47
- config.integrate do |with|
48
- with.test_framework :rspec
49
- with.library :rails
50
- end
51
- end
52
-
53
- def mock_omniauth_request(
54
- uid: nil, first_name: nil, last_name: nil, title: nil, nickname: nil, faculty_status: nil,
55
- uuid: nil, support_identifier: nil, self_reported_role: nil, school_type: nil
56
- )
57
- extra_hash = {
58
- 'raw_info' => {
59
- 'faculty_status' => faculty_status,
60
- 'uuid' => uuid || SecureRandom.uuid,
61
- 'support_identifier' => support_identifier || "cs_#{SecureRandom.hex(4)}",
62
- 'self_reported_role' => self_reported_role,
63
- 'school_type' => school_type
64
- }
65
- }
66
-
67
- OpenStruct.new(
68
- env: {
69
- 'omniauth.auth' => OpenStruct.new(
70
- uid: uid || SecureRandom.random_number(10000000),
71
- provider: "openstax",
72
- info: OpenStruct.new(
73
- nickname: nickname || "",
74
- first_name: first_name || "",
75
- last_name: last_name || "",
76
- title: title || ""
77
- ),
78
- credentials: OpenStruct.new(access_token: "foo"),
79
- extra: OpenStruct.new(extra_hash)
80
- )
81
- }
82
- )
83
- end
84
-
85
- def remove_faculty_status!(omniauth_request)
86
- omniauth_request.env["omniauth.auth"].extra.raw_info.delete("faculty_status")
87
- end
88
-
89
- def remove_nickname!(omniauth_request)
90
- omniauth_request.env["omniauth.auth"].info.nickname = nil
91
- end
92
-
93
- def with_stubbing(value)
94
- begin
95
- original = OpenStax::Accounts.configuration.enable_stubbing
96
- OpenStax::Accounts.configuration.enable_stubbing = value
97
- yield
98
- ensure
99
- OpenStax::Accounts.configuration.enable_stubbing = original
100
- end
101
- end
102
-
103
- def silence_omniauth
104
- previous_logger = OmniAuth.config.logger
105
- OmniAuth.config.logger = Logger.new("/dev/null")
106
- yield
107
- ensure
108
- OmniAuth.config.logger = previous_logger
109
- end
data/spec/vcr_helper.rb DELETED
@@ -1,14 +0,0 @@
1
- require 'vcr'
2
- require 'webmock/rspec'
3
-
4
- VCR.configure do |c|
5
- c.cassette_library_dir = 'spec/cassettes'
6
- c.hook_into :webmock
7
- c.configure_rspec_metadata!
8
- c.allow_http_connections_when_no_cassette = true
9
- end
10
-
11
- VCR_OPTS = {
12
- record: :none, # This should be :none before pushing
13
- allow_unused_http_interactions: false
14
- }