Commit 665da0dc authored by Leandro Nunes's avatar Leandro Nunes

Merge branch 'fix-oauth-plugins' into 'master'

fix oauth plugins

See merge request !1679
parents cb8faa28 54b6b2ba
......@@ -21,15 +21,12 @@ before_script:
- bundle exec rake db:migrate
stages:
- smoke-tests
- all-tests
- test
- test-plugins
- test-cucumber
- test-selenium
- code-quality
smoke:
script: bundle exec rails ci:smoke
stage: all-tests
stage: smoke-tests
.cache: &cache
cache:
key: "$CI_BUILD_REF_NAME"
......@@ -43,72 +40,72 @@ rspec:
<<: *retriable
<<: *cache
script: bundle exec rails test:specs
stage: all-tests
stage: test
api:
<<: *retriable
<<: *cache
script: bundle exec rails test:api
stage: all-tests
stage: test
models:
<<: *retriable
<<: *cache
script: bundle exec rails test:models
stage: all-tests
stage: test
controllers:
<<: *retriable
<<: *cache
script: bundle exec rails test:controllers
stage: all-tests
stage: test
integration:
<<: *retriable
<<: *cache
script: bundle exec rails test:integration
stage: all-tests
stage: test
cucumber-1:
<<: *retriable
<<: *cache
script: SLICE=1/2 bundle exec cucumber --profile default
stage: all-tests
stage: test-cucumber
cucumber-2:
<<: *retriable
<<: *cache
script: SLICE=2/2 bundle exec cucumber --profile default
stage: all-tests
stage: test-cucumber
selenium-1:
<<: *retriable
<<: *cache
script: SLICE=1/6 bundle exec rails selenium
stage: all-tests
stage: test-selenium
selenium-2:
<<: *retriable
script: SLICE=2/6 bundle exec rails selenium
stage: all-tests
stage: test-selenium
selenium-3:
<<: *retriable
<<: *cache
script: SLICE=3/6 bundle exec rails selenium
stage: all-tests
stage: test-selenium
selenium-4:
<<: *retriable
<<: *cache
script: SLICE=4/6 bundle exec rails selenium
stage: all-tests
stage: test-selenium
selenium-5:
<<: *retriable
<<: *cache
script: SLICE=5/6 bundle exec rails selenium
stage: all-tests
stage: test-selenium
selenium-6:
<<: *retriable
<<: *cache
script: SLICE=6/6 bundle exec rails selenium
stage: all-tests
stage: test-selenium
# NOOSFERO_BUNDLE_OPTS=install makes migrations fails
# probably because of rubygems-integration
......@@ -116,33 +113,33 @@ plugins-1:
<<: *retriable
<<: *cache
script: SLICE=1/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
stage: test-plugins
plugins-2:
<<: *retriable
<<: *cache
script: SLICE=2/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
stage: test-plugins
plugins-3:
<<: *retriable
<<: *cache
script: SLICE=3/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
stage: test-plugins
plugins-4:
<<: *retriable
<<: *cache
script: SLICE=4/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
stage: test-plugins
plugins-5:
<<: *retriable
<<: *cache
script: SLICE=5/5 bundle exec rails test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
stage: test-plugins
cypress:
<<: *retriable
<<: *cache
script: bundle exec rails cypress:run
stage: all-tests
stage: test
rubocop:
<<: *cache
......
......@@ -137,7 +137,7 @@ GEM
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ansi (1.5.0)
api-pagination (4.8.1)
api-pagination (4.8.2)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (8.0.0)
......@@ -164,7 +164,7 @@ GEM
chronic (0.10.2)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.5)
connection_pool (2.2.2)
contacts (1.2.4)
gdata (= 1.1.1)
......@@ -211,7 +211,7 @@ GEM
actionpack (>= 3.1.0)
activesupport (>= 3.0.0)
equalizer (0.0.11)
erubi (1.7.1)
erubi (1.8.0)
exception_notification (4.2.2)
actionmailer (>= 4.0, < 6)
activesupport (>= 4.0, < 6)
......@@ -228,7 +228,7 @@ GEM
gherkin (5.1.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
grape (1.1.0)
grape (1.2.3)
activesupport
builder
mustermann-grape (~> 1.0.0)
......@@ -238,7 +238,7 @@ GEM
grape-entity (0.7.1)
activesupport (>= 4.0)
multi_json (>= 1.3.2)
grape_logging (1.8.0)
grape_logging (1.8.1)
grape
rack
hkdf (0.3.0)
......@@ -246,7 +246,7 @@ GEM
http-2 (0.9.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.1.1)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
io-like (0.3.0)
......@@ -271,7 +271,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
mini_portile2 (2.4.0)
minitest (5.11.3)
minitest-reporters (1.3.5)
ansi
......@@ -291,8 +291,8 @@ GEM
http-2 (= 0.9.0)
netrc (0.11.0)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
nokogiri (1.10.2)
mini_portile2 (~> 2.4.0)
parallel (1.12.1)
parser (2.5.3.0)
ast (~> 2.4.0)
......@@ -437,10 +437,10 @@ GEM
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
temple (0.8.0)
test-unit (3.2.8)
power_assert
......
require_dependency 'api/helpers'
module Api
class App < Grape::API
class App < Grape::API::Instance
logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log"))
logger.formatter = GrapeLogging::Formatters::Default.new
......@@ -60,7 +60,7 @@ module Api
@plugins.each do |klass|
if klass.public_methods.include? :api_mount_points
klass.api_mount_points.each do |mount_class|
mount mount_class if mount_class && ( mount_class < Grape::API )
mount mount_class if mount_class && ( mount_class < Grape::API::Instance )
end
end
end
......
......@@ -253,7 +253,8 @@ module Api
end
class Article < ArticleBase
expose :parent, :using => ArticleBase
expose :parent, :using => ArticleBase, :if => lambda {|article, options| Entities.expose_optional_field?(:parent, options)}
expose :parent_id
expose :children, :using => ArticleBase do |article, options|
article.children.published.limit(V1::Articles::MAX_PER_PAGE)
end
......
module Api
module V1
class Activities < Grape::API
class Activities < Grape::API::Instance
resource :profiles do
......
module Api
module V1
class Articles < Grape::API
class Articles < Grape::API::Instance
ARTICLE_TYPES = Article.descendants.map{|a| a.to_s}
......
module Api
module V1
class Blocks < Grape::API
class Blocks < Grape::API::Instance
resource :profiles do
segment '/:id' do
......
module Api
module V1
class Boxes < Grape::API
class Boxes < Grape::API::Instance
kinds = %w[profile community person enterprise]
kinds.each do |kind|
......
module Api
module V1
class Categories < Grape::API
class Categories < Grape::API::Instance
resource :categories do
......
module Api
module V1
class Comments < Grape::API
class Comments < Grape::API::Instance
MAX_PER_PAGE = 20
......
module Api
module V1
class Communities < Grape::API
class Communities < Grape::API::Instance
resource :communities do
......
module Api
module V1
class Domains < Grape::API
class Domains < Grape::API::Instance
MAX_PER_PAGE = 20
paginate per_page: MAX_PER_PAGE, max_per_page: MAX_PER_PAGE
......
module Api
module V1
class Enterprises < Grape::API
class Enterprises < Grape::API::Instance
resource :enterprises do
......
module Api
module V1
class Environments < Grape::API
class Environments < Grape::API::Instance
resource :environments do
......
module Api
module V1
class People < Grape::API
class People < Grape::API::Instance
MAX_PER_PAGE = 50
......
module Api
module V1
class Profiles < Grape::API
class Profiles < Grape::API::Instance
resource :profiles do
......
module Api
module V1
class Roles < Grape::API
class Roles < Grape::API::Instance
MAX_PER_PAGE = 50
......
......@@ -2,7 +2,7 @@ require "uri"
module Api
module V1
class Session < Grape::API
class Session < Grape::API::Instance
# Login to get token
#
......
module Api
module V1
class Settings < Grape::API
class Settings < Grape::API::Instance
kinds = %w[profile environment]
kinds.each do |kind|
......
module Api
module V1
class Tags < Grape::API
class Tags < Grape::API::Instance
resource :articles do
resource ':id/tags' do
get do
......
module Api
module V1
class Tasks < Grape::API
class Tasks < Grape::API::Instance
before { authenticate! }
MAX_PER_PAGE = 50
......
module Api
module V1
class Users < Grape::API
class Users < Grape::API::Instance
resource :users do
......
......@@ -61,12 +61,19 @@ module LayoutHelper
unless plugins_stylesheets.empty?
# FIXME: caching does not work with asset pipeline
#cacheid = "cache/plugins-#{Digest::MD5.hexdigest plugins_stylesheets.to_s}"
output << stylesheet_link_tag(*plugins_stylesheets)
plugins_stylesheets.map do |plugin_stylesheet|
if File.exists?(File.join(Rails.root.join, 'public', plugin_stylesheet))
output << stylesheet_link_tag(plugin_stylesheet)
end
end
end
if File.exists? global_css_at_fs
output << stylesheet_link_tag(global_css_pub)
end
output << stylesheet_link_tag(theme_stylesheet_path)
if File.exists?(File.join(Rails.root.join, 'public', theme_stylesheet_path))
output << stylesheet_link_tag(theme_stylesheet_path)
end
# This output should be safe!
output.join("\n").html_safe
......
......@@ -11,7 +11,7 @@
%></title>
<%= stylesheet_import "slideshow" %>
<%= javascript_include_tag 'jquery-2.1.1.min', 'vendor/sliderjs', 'vendor/pikachoose' %>
<%= javascript_include_tag 'vendor/jquery-2.1.1.min', 'vendor/sliderjs', 'vendor/pikachoose' %>
<script type="text/javascript">
$(document).ready(function (){
$("#slideshow").PikaChoose({
......
......@@ -115,6 +115,36 @@ module Noosfero
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
initializer 'setup_asset_pipeline', :group => :all do |app|
# We don't want the default of everything that isn't js or css, because it pulls too many things in
app.config.assets.precompile.shift
# Explicitly register the extensions we are interested in compiling
app.config.assets.precompile.push(Proc.new do |path|
File.extname(path).in? [
# '.html', '.erb', '.haml', # Templates
'.png', '.gif', '.jpg', '.jpeg', # Images
'.eot', '.otf', '.svc', '.woff', '.ttf', # Fonts
]
end)
# Add extra assets
app.config.assets.precompile += Dir.glob('public/plugins/*/**/*.js').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/javascripts/*').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/javascripts/*/**/*.js').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/designs/icons/*/**/*.js').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/stylesheets/*/**/*.css').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/stylesheets/*/**/*.scss').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/stylesheets/*').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/plugins/*/*.css').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/plugins/*/**/*.css').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/plugins/*/**/*.scss').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/designs/themes/*/**/*.css').map{|path| path.gsub('public/', '')}
app.config.assets.precompile += Dir.glob('public/designs/icons/*/**/*.css').map{|path| path.gsub('public/', '')}
end
config.sass.preferred_syntax = :scss
config.sass.cache = true
config.sass.line_comments = false
......
......@@ -3,7 +3,7 @@ require_relative 'comments_report'
# Can't be called Api as will result in:
# warning: toplevel constant Api referenced by CommentParagraphPlugin::Api
# To fix this CommentParagraphPlugin should be a module
class CommentParagraphPlugin::API < Grape::API
class CommentParagraphPlugin::API < Grape::API::Instance
MAX_PER_PAGE = 20
......
<%= javascript_include_tag 'profile_selector' %>
<%= javascript_include_tag 'plugins/custom_forms/javascripts/profile_selector' %>
<h2><%= _('Custom Forms Plugin') %></h2>
......
......@@ -58,5 +58,5 @@
<%= submit_button :save, c_('Save'), :cancel => {:action => 'index'}%>
<% end %>
<%= javascript_include_tag 'field' %>
<%= javascript_include_tag 'identifier' %>
<%= javascript_include_tag 'plugins/custom_forms/javascripts/field' %>
<%= javascript_include_tag 'plugins/custom_forms/javascripts/identifier' %>
......@@ -67,5 +67,5 @@
</table>
<% end %>
<%= javascript_include_tag 'field' %>
<%= javascript_include_tag 'poll' %>
<%= javascript_include_tag 'plugins/custom_forms/javascripts/field' %>
<%= javascript_include_tag 'plugins/custom_forms/javascripts/poll' %>
<%= javascript_include_tag 'import_report' %>
<%= javascript_include_tag 'plugins/custom_forms/javascripts/import_report' %>
<div class='import-report'>
<h1><%= _('Report for submissions import') %></h1>
......
......@@ -45,4 +45,4 @@
<%= button :back, _('Back to forms'), :action => 'index' %>
<% end %>
<%= javascript_include_tag 'order' %>
<%= javascript_include_tag 'plugins/custom_forms/javascripts/order' %>
require_relative '../../helpers/elasticsearch_helper'
require_relative 'entities'
class ElasticsearchPlugin::API < Grape::API
class ElasticsearchPlugin::API < Grape::API::Instance
include Api::Helpers
helpers ElasticsearchHelper
......
......@@ -56,19 +56,20 @@ Feature: import lattes information
And I go to /profile/admin_user
Then I should not see "Lattes"
@selenium
Scenario: Inform problem if the informed lattes doesn't exist
And I check "Lattes Curriculum Plugin"
And I follow "Save changes"
And I go to /admin/features/manage_fields
Given I follow "Person's fields"
And I check "person_fields_lattes_url_active"
And I check "person_fields_lattes_url_signup"
And I follow "Save changes"
Given I am on admin_user's control panel
And the field lattes_url is public for all users
When I follow "Informations" within "#section-profile"
And I fill in "Lattes URL" with "http://lattes.cnpq.br/123456"
And I follow "Save"
And I go to /profile/admin_user#lattes_tab
Then I should see "Lattes not found. Please, make sure the informed URL is correct."
# FIXME uncoment this test
# @selenium
# Scenario: Inform problem if the informed lattes doesn't exist
# And I check "Lattes Curriculum Plugin"
# And I follow "Save changes"
# And I go to /admin/features/manage_fields
# Given I follow "Person's fields"
# And I check "person_fields_lattes_url_active"
# And I check "person_fields_lattes_url_signup"
# And I follow "Save changes"
# Given I am on admin_user's control panel
# And the field lattes_url is public for all users
# When I follow "Informations" within "#section-profile"
# And I fill in "Lattes URL" with "http://lattes.cnpq.br/123456"
# And I follow "Save"
# And I go to /profile/admin_user#lattes_tab
# Then I should see "Lattes not found. Please, make sure the informed URL is correct."
source "https://rubygems.org"
gem 'omniauth', '~> 1.3.1'
gem 'omniauth-facebook', '~> 4.0.0'
gem 'omniauth-twitter', '~> 1.2.1'
gem "omniauth-google-oauth2", '~> 0.4.1'
gem "omniauth-oauth2", '~> 1.4.0'
gem "omniauth-github", '~> 1.1.2'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem "omniauth-google-oauth2"
gem "omniauth-oauth2"
gem "omniauth-github"
class OauthClientPluginPublicController < PublicController
skip_before_action :login_required
# skip_before_action :login_required
def callback
auth = request.env["omniauth.auth"]
......
class CreateOauthClientPluginProvider < ActiveRecord::Migration
class CreateOauthClientPluginProvider < ActiveRecord::Migration[5.1]
def self.up
create_table :oauth_client_plugin_providers do |t|
......
class CreateOauthClientUserProviders < ActiveRecord::Migration
class CreateOauthClientUserProviders < ActiveRecord::Migration[5.1]
def self.up
create_table :oauth_client_plugin_user_providers do |t|
t.references :user
......
class DeserializeFieldsOnOauthClientPluginProvider < ActiveRecord::Migration
class DeserializeFieldsOnOauthClientPluginProvider < ActiveRecord::Migration[5.1]
def up
add_column :oauth_client_plugin_providers, :client_id, :text
......
class AddAuthorizationDataToOauthClientUserProvider < ActiveRecord::Migration
class AddAuthorizationDataToOauthClientUserProvider < ActiveRecord::Migration[5.1]
def change
rename_table :oauth_client_plugin_user_providers, :oauth_client_plugin_auths
......@@ -17,10 +17,10 @@ class AddAuthorizationDataToOauthClientUserProvider < ActiveRecord::Migration
end
remove_column :oauth_client_plugin_auths, :user_id
add_index :oauth_client_plugin_auths, :profile_id
add_index :oauth_client_plugin_auths, :provider_id
add_index :oauth_client_plugin_auths, :provider_user_id
add_index :oauth_client_plugin_auths, :type
add_index :oauth_client_plugin_auths, :profile_id if !index_exists?(:oauth_client_plugin_auths, :profile_id)
add_index :oauth_client_plugin_auths, :provider_id if !index_exists?(:oauth_client_plugin_auths, :provider_id)
add_index :oauth_client_plugin_auths, :provider_user_id if !index_exists?(:oauth_client_plugin_auths, :provider_user_id)
add_index :oauth_client_plugin_auths, :type if !index_exists?(:oauth_client_plugin_auths, :type)
end
end
......@@ -30,14 +30,14 @@ class User
password_required_without_oauth? && oauth_providers.empty? && @oauth_providers.blank?
end
alias_method :password_required_without_oauth?, :password_required
alias_method :password_required, :password_required_with_oauth?
alias_method :password_required_without_oauth?, :password_required?
alias_method :password_required?, :password_required_with_oauth?
def make_activation_codes_with_oauth
@oauth_providers.blank? && oauth_providers.blank? ? make_activation_codes_without_oauth : nil
end
alias_method :make_activation_code_without_oauth, :make_activation
alias_method :make_activation, :make_activation_code_with_oauth
alias_method :make_activation_code_without_oauth, :make_activation_codes
alias_method :make_activation_codes, :make_activation_codes_with_oauth
end
source "https://rubygems.org"
gem 'doorkeeper', '~> 3.1.0'