diff --git a/plugins/serpro_captcha/Gemfile b/plugins/serpro_captcha/Gemfile deleted file mode 100644 index 6b9ce46..0000000 --- a/plugins/serpro_captcha/Gemfile +++ /dev/null @@ -1 +0,0 @@ -gem 'webmock' diff --git a/plugins/serpro_captcha/README.md b/plugins/serpro_captcha/README.md deleted file mode 100644 index e69de29..0000000 --- a/plugins/serpro_captcha/README.md +++ /dev/null diff --git a/plugins/serpro_captcha/controllers/serpro_captcha_plugin_admin_controller.rb b/plugins/serpro_captcha/controllers/serpro_captcha_plugin_admin_controller.rb deleted file mode 100644 index a8dddab..0000000 --- a/plugins/serpro_captcha/controllers/serpro_captcha_plugin_admin_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -class SerproCaptchaPluginAdminController < PluginAdminController - - append_view_path File.join(File.dirname(__FILE__) + '/../views') - - def index - end - - def update - if @environment.update_attributes(params[:environment]) - session[:notice] = _('Captcha configuration updated successfully.') - else - session[:notice] = _('Captcha configuration could not be saved.') - end - render :action => 'index' - end - -end diff --git a/plugins/serpro_captcha/fixtures/ldap.yml.dist b/plugins/serpro_captcha/fixtures/ldap.yml.dist deleted file mode 100644 index 720e80c..0000000 --- a/plugins/serpro_captcha/fixtures/ldap.yml.dist +++ /dev/null @@ -1,15 +0,0 @@ -server: - host: "127.0.0.1" - port: 389 - account: "uid=ldap_user,,ou=person,dc=noosfero,dc=org" - account_password: "ldap_pass" - base_dn: "dc=noosfero,dc=org" - attr_login: "uid" - attr_fullname: "cn" - attr_mail: "mail" - onthefly_register: true - filter: "" - tls: false -user: - login: 'valid_ldap_login' - password: 'valid_ldap_password' diff --git a/plugins/serpro_captcha/lib/ext/environment.rb b/plugins/serpro_captcha/lib/ext/environment.rb deleted file mode 100644 index 6b1f346..0000000 --- a/plugins/serpro_captcha/lib/ext/environment.rb +++ /dev/null @@ -1,35 +0,0 @@ -require_dependency 'environment' - -class Environment - - #Captcha settings - settings_items :serpro_captcha_plugin, :type => ActiveSupport::HashWithIndifferentAccess, :default => {} - -# settings_items :verify_uri, :type => :string, :default => 'http://captcha.servicoscorporativos.serpro.gov.br/captchavalidar/1.0.0/validar' -# settings_items :serpro_client_id, :type => :string, :default => 'fdbcdc7a0b754ee7ae9d865fda740f17' - - attr_accessible :serpro_captcha_plugin_attributes, :serpro_captcha_verify_uri, :serpro_captcha_client_id - - def serpro_captcha_plugin_attributes - self.serpro_captcha_plugin || {} - end - - def serpro_captcha_verify_uri= verify_uri - self.serpro_captcha_plugin = {} if self.serpro_captcha_plugin.blank? - self.serpro_captcha_plugin['serpro_captcha_verify_uri'] = verify_uri - end - - def serpro_captcha_verify_uri - self.serpro_captcha_plugin['serpro_captcha_verify_uri'] - end - - def serpro_captcha_client_id= client_id - self.serpro_captcha_plugin = {} if self.serpro_captcha_plugin.blank? - self.serpro_captcha_plugin['serpro_captcha_client_id'] = client_id - end - - def serpro_captcha_client_id - self.serpro_captcha_plugin['serpro_captcha_client_id'] - end - -end diff --git a/plugins/serpro_captcha/lib/serpro_captcha_plugin.rb b/plugins/serpro_captcha/lib/serpro_captcha_plugin.rb deleted file mode 100644 index 6b7fd7b..0000000 --- a/plugins/serpro_captcha/lib/serpro_captcha_plugin.rb +++ /dev/null @@ -1,20 +0,0 @@ -class SerproCaptchaPlugin < Noosfero::Plugin - - def self.plugin_name - _('Serpro\'s captcha plugin') - end - - def self.plugin_description - _("Provides a plugin to Serpro's captcha infrastructure.") - end - - def self.api_mount_points - [SerproCaptchaPlugin::API ] - end - - def test_captcha(remote_ip, params, environment) - scv = SerproCaptchaVerification.new - return scv.verify_serpro_captcha(environment.serpro_captcha_client_id, params[:txtToken_captcha_serpro_gov_br], params[:captcha_text], environment.serpro_captcha_verify_uri) - end - -end diff --git a/plugins/serpro_captcha/lib/serpro_captcha_verification.rb b/plugins/serpro_captcha/lib/serpro_captcha_verification.rb deleted file mode 100644 index 1af51f5..0000000 --- a/plugins/serpro_captcha/lib/serpro_captcha_verification.rb +++ /dev/null @@ -1,31 +0,0 @@ -class SerproCaptchaVerification - - # return true or a hash with the error - # :user_message, :status, :log_message, :javascript_console_message - def verify_serpro_captcha(client_id, token, captcha_text, verify_uri) - msg_icve = _('Internal captcha validation error') - msg_esca = 'Environment serpro_captcha_plugin_attributes' - return hash_error(msg_icve, 500, nil, "#{msg_esca} verify_uri not defined") if verify_uri.nil? - return hash_error(msg_icve, 500, nil, "#{msg_esca} client_id not defined") if client_id.nil? - return hash_error(_("Error processing token validation"), 500, nil, _("Missing Serpro's Captcha token")) unless token - return hash_error(_('Captcha text has not been filled'), 403) unless captcha_text - uri = URI(verify_uri) - http = Net::HTTP.new(uri.host, uri.port) - request = Net::HTTP::Post.new(uri.path) - verify_string = "#{client_id}&#{token}&#{captcha_text}" - request.body = verify_string - body = http.request(request).body - return true if body == '1' - return hash_error(_("Internal captcha validation error"), 500, body, "Unable to reach Serpro's Captcha validation service") if body == "Activity timed out" - return hash_error(_("Wrong captcha text, please try again"), 403) if body == '0' - return hash_error(_("Serpro's captcha token not found"), 500) if body == '2' - return hash_error(_("No data sent to validation server or other serious problem"), 500) if body == -1 - #Catches all errors at the end - return hash_error(_("Internal captcha validation error"), 500, nil, "Error validating Serpro's captcha service returned: #{body}") - end - - def hash_error(user_message, status, log_message=nil, javascript_console_message=nil) - {user_message: user_message, status: status, log_message: log_message, javascript_console_message: javascript_console_message} - end - -end diff --git a/plugins/serpro_captcha/po/de/ldap.po b/plugins/serpro_captcha/po/de/ldap.po deleted file mode 100644 index cd92fcc..0000000 --- a/plugins/serpro_captcha/po/de/ldap.po +++ /dev/null @@ -1,99 +0,0 @@ -# German translation of noosfero. -# Copyright (C) 2009-2013 Josef Spillner -# Copyright (C) 2009, 2011 Ronny Kursawe -# This file is distributed under the same license as the noosfero package. -# Josef Spillner , 2009. -# -msgid "" -msgstr "" -"Project-Id-Version: 1.2~rc2-23-g29aba34\n" -"POT-Creation-Date: 2015-08-06 18:47-0300\n" -"PO-Revision-Date: 2014-12-12 14:23+0200\n" -"Last-Translator: Michal Čihař \n" -"Language-Team: German \n" -"Language: de\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 2.2-dev\n" - -#: plugins/ldap/lib/serpro_captcha_plugin.rb:11 -#, fuzzy -msgid "A plugin that add ldap support." -msgstr "Ein Plugin, welches dies und jenes tut." - -#: plugins/ldap/controllers/serpro_captcha_plugin_admin_controller.rb:10 -#, fuzzy -msgid "Ldap configuration updated successfully." -msgstr "Optionen erfolgreich aktualisiert." - -#: plugins/ldap/controllers/serpro_captcha_plugin_admin_controller.rb:12 -#, fuzzy -msgid "Ldap configuration could not be saved." -msgstr "Die Konfiguration konnte nicht gespeichert werden" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:1 -#, fuzzy -msgid "Ldap Management" -msgstr "Inhalt verwalten" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:8 -msgid "Value" -msgstr "Wert" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:11 -msgid "Host" -msgstr "Rechner" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:15 -msgid "Port" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:19 -#, fuzzy -msgid "Account" -msgstr "Preisermäßigung" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:23 -#, fuzzy -msgid "Account Password" -msgstr "Derzeitiges Passwort" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:27 -msgid "Base DN" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:31 -#, fuzzy -msgid "LDAP Filter" -msgstr "Filter" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:35 -#, fuzzy -msgid "On the fly creation" -msgstr "Im letzten Monat" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:39 -msgid "LDAPS" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:46 -msgid "Attributes" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:53 -#, fuzzy -msgid "Fullname" -msgstr "Vollständiger Name" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:57 -#, fuzzy -msgid "Mail" -msgstr "E-Mail" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:65 -#, fuzzy -msgid "Back to plugins administration panel" -msgstr "Zurück zum Adminfeld" diff --git a/plugins/serpro_captcha/po/ldap.pot b/plugins/serpro_captcha/po/ldap.pot deleted file mode 100644 index 812412e..0000000 --- a/plugins/serpro_captcha/po/ldap.pot +++ /dev/null @@ -1,86 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: 1.2~rc2-23-g29aba34\n" -"POT-Creation-Date: 2015-08-06 18:47-0300\n" -"PO-Revision-Date: 2015-08-06 17:21-0300\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" - -#: plugins/ldap/lib/serpro_captcha_plugin.rb:11 -msgid "A plugin that add ldap support." -msgstr "" - -#: plugins/ldap/controllers/serpro_captcha_plugin_admin_controller.rb:10 -msgid "Ldap configuration updated successfully." -msgstr "" - -#: plugins/ldap/controllers/serpro_captcha_plugin_admin_controller.rb:12 -msgid "Ldap configuration could not be saved." -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:1 -msgid "Ldap Management" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:8 -msgid "Value" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:11 -msgid "Host" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:15 -msgid "Port" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:19 -msgid "Account" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:23 -msgid "Account Password" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:27 -msgid "Base DN" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:31 -msgid "LDAP Filter" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:35 -msgid "On the fly creation" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:39 -msgid "LDAPS" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:46 -msgid "Attributes" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:53 -msgid "Fullname" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:57 -msgid "Mail" -msgstr "" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:65 -msgid "Back to plugins administration panel" -msgstr "" diff --git a/plugins/serpro_captcha/po/pt/ldap.po b/plugins/serpro_captcha/po/pt/ldap.po deleted file mode 100644 index 8561a70..0000000 --- a/plugins/serpro_captcha/po/pt/ldap.po +++ /dev/null @@ -1,93 +0,0 @@ -# translation of noosfero.po to -# Krishnamurti Lelis Lima Vieira Nunes , 2007. -# noosfero - Brazilian Portuguese translation -# Copyright (C) 2007, -# Forum Brasileiro de Economia Solidaria -# Copyright (C) 2007, -# Ynternet.org Foundation -# This file is distributed under the same license as noosfero itself. -# Joenio Costa , 2008. -# -# -msgid "" -msgstr "" -"Project-Id-Version: 1.2~rc2-23-g29aba34\n" -"POT-Creation-Date: 2015-08-06 18:47-0300\n" -"PO-Revision-Date: 2014-12-18 18:40-0200\n" -"Last-Translator: Luciano Prestes Cavalcanti \n" -"Language-Team: Portuguese \n" -"Language: pt\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 2.0\n" - -#: plugins/ldap/lib/serpro_captcha_plugin.rb:11 -msgid "A plugin that add ldap support." -msgstr "Um plugin que adiciona suporte a ldap." - -#: plugins/ldap/controllers/serpro_captcha_plugin_admin_controller.rb:10 -msgid "Ldap configuration updated successfully." -msgstr "Configuração do Ldap atualizada com sucesso." - -#: plugins/ldap/controllers/serpro_captcha_plugin_admin_controller.rb:12 -msgid "Ldap configuration could not be saved." -msgstr "Configuração do Ldap não pode ser salva." - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:1 -msgid "Ldap Management" -msgstr "Gerenciamento do Ldap" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:8 -msgid "Value" -msgstr "Valor" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:11 -msgid "Host" -msgstr "Host" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:15 -msgid "Port" -msgstr "Porta" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:19 -msgid "Account" -msgstr "Conta" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:23 -msgid "Account Password" -msgstr "Senha da conta" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:27 -msgid "Base DN" -msgstr "DN Base" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:31 -msgid "LDAP Filter" -msgstr "Filtro LDAP" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:35 -msgid "On the fly creation" -msgstr "Criação sob-demanda" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:39 -msgid "LDAPS" -msgstr "LDAPS" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:46 -msgid "Attributes" -msgstr "Atributos" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:53 -msgid "Fullname" -msgstr "Nome completo" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:57 -msgid "Mail" -msgstr "Mail" - -#: plugins/ldap/views/serpro_captcha_plugin_admin/index.html.erb:65 -msgid "Back to plugins administration panel" -msgstr "Voltar ao painel de administração" diff --git a/plugins/serpro_captcha/test/functional/account_controller_plugin_test.rb b/plugins/serpro_captcha/test/functional/account_controller_plugin_test.rb deleted file mode 100644 index 4b0e63a..0000000 --- a/plugins/serpro_captcha/test/functional/account_controller_plugin_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -# Re-raise errors caught by the controller. -class AccountController; def rescue_action(e) raise e end; end - -class AccountControllerPluginTest < ActionController::TestCase - - def setup - @controller = AccountController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @environment = Environment.default - @environment.enabled_plugins = ['SerproCaptchaPlugin'] - @environment.save! - end - -end diff --git a/plugins/serpro_captcha/test/functional/serpro_captcha_test.rb b/plugins/serpro_captcha/test/functional/serpro_captcha_test.rb deleted file mode 100644 index 3860b36..0000000 --- a/plugins/serpro_captcha/test/functional/serpro_captcha_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# require File.dirname(__FILE__) + '/../../../../test/test_helper' -# require File.dirname(__FILE__) + '/../../controllers/serpro_captcha_plugin_admin_controller' -# -# # Re-raise errors caught by the controller. -# class SerproCaptchaPluginAdminController; def rescue_action(e) raise e end; end -# -# class SerproCaptchaPluginAdminControllerTest < ActionController::TestCase -# -# def setup -# @environment = Environment.default -# user_login = create_admin_user(@environment) -# login_as(user_login) -# @admin = User[user_login].person -# @environment.enabled_plugins = ['SerproCaptchaPlugin'] -# @environment.serpro_captcha_plugin_host="http://somehost" -# @environment.save! -# end -# -# should 'detected error, Name or service not known, for Serpro captcha communication' do -# environment = Environment.default -# environment.serpro_captcha_verify_uri = 'http://someserverthatdoesnotexist.mycompanythatdoesnotexist.com/validate' -# environment.serpro_captcha_client_id = '000000000000' -# environment.save! -# params = {:login => "newuserapi", :password => "newuserapi", :password_confirmation => "newuserapi", :email => "newuserapi@email.com", -# :txtToken_captcha_serpro_gov_br => '4324343', :captcha_text => '4030320'} -# post "/api/v1/register?#{params.to_query}" -# message = JSON.parse(last_response.body)['javascript_console_message'] -# assert_equal "Serpro captcha error: getaddrinfo: Name or service not known", message -# end diff --git a/plugins/serpro_captcha/test/test_helper.rb b/plugins/serpro_captcha/test/test_helper.rb deleted file mode 100644 index c4539b5..0000000 --- a/plugins/serpro_captcha/test/test_helper.rb +++ /dev/null @@ -1,65 +0,0 @@ -require "#{Rails.root}/lib/noosfero/api/helpers" - -class ActiveSupport::TestCase - - include Rack::Test::Methods - - def app - Noosfero::API::API - end - - def pass_captcha(mocked_url, captcha_verification_body) - stub_request(:post, mocked_url). - with(:body => captcha_verification_body, - :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}). - to_return(:status => 200, :body => "1", :headers => {'Content-Length' => 1}) - end - - def fail_captcha_text(mocked_url, captcha_verification_body) - stub_request(:post, mocked_url). - with(:body => captcha_verification_body, - :headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}). - to_return(:status => 200, :body => "0", :headers => {'Content-Length' => 1}) - end - - def login_with_captcha - json = do_login_captcha_from_api - @private_token = json["private_token"] - @params = { "private_token" => @private_token} - json - end - - ## Performs a login using the session.rb but mocking the - ## real HTTP request to validate the captcha. - def do_login_captcha_from_api - post "/api/v1/login-captcha" - json = JSON.parse(last_response.body) - json - end - - def login_api - @environment = Environment.default - @user = User.create!(:login => 'testapi', :password => 'testapi', :password_confirmation => 'testapi', :email => 'test@test.org', :environment => @environment) - @user.activate - @person = @user.person - - post "/api/v1/login?login=testapi&password=testapi" - json = JSON.parse(last_response.body) - @private_token = json["private_token"] - unless @private_token - @user.generate_private_token! - @private_token = @user.private_token - end - - @params = {:private_token => @private_token} - end - attr_accessor :private_token, :user, :person, :params, :environment - - private - - def json_response_ids(kind) - json = JSON.parse(last_response.body) - json[kind.to_s].map {|c| c['id']} - end - -end diff --git a/plugins/serpro_captcha/test/unit/ext/environment_test.rb b/plugins/serpro_captcha/test/unit/ext/environment_test.rb deleted file mode 100644 index 3d65cc4..0000000 --- a/plugins/serpro_captcha/test/unit/ext/environment_test.rb +++ /dev/null @@ -1,186 +0,0 @@ -# require File.dirname(__FILE__) + '/../../../../../test/test_helper' -# -# class EnvironmentTest < ActiveSupport::TestCase -# -# def setup -# @enviroment = Environment.default -# end -# -# should 'have serpro_captcha_plugin variable defined' do -# assert_equal Hash, @enviroment.serpro_captcha_plugin.class -# end -# -# should 'return an empty hash by default on serpro_captcha_plugin_attributes method' do -# assert_equal Hash.new, @enviroment.serpro_captcha_plugin_attributes -# end -# -# should 'serpro_captcha_plugin_host= define the ldap host' do -# host = "http://something" -# @enviroment.serpro_captcha_plugin_host= host -# assert_equal host, @enviroment.serpro_captcha_plugin['host'] -# end -# -# should 'serpro_captcha_plugin_host return the defined ldap host' do -# host = "http://something" -# @enviroment.serpro_captcha_plugin_host= host -# assert_equal host, @enviroment.serpro_captcha_plugin_host -# end -# -# should 'serpro_captcha_plugin_port= define the ldap port' do -# value = 255 -# @enviroment.serpro_captcha_plugin_port= value -# assert_equal value, @enviroment.serpro_captcha_plugin['port'] -# end -# -# should 'serpro_captcha_plugin_port return the defined ldap port' do -# value = 255 -# @enviroment.serpro_captcha_plugin_port= value -# assert_equal value, @enviroment.serpro_captcha_plugin_port -# end -# -# should 'default serpro_captcha_plugin_port be 389' do -# assert_equal 389, @enviroment.serpro_captcha_plugin_port -# end -# -# should 'serpro_captcha_plugin_account= define the ldap acccount' do -# value = 'uid=sector,ou=Service,ou=corp,dc=company,dc=com,dc=br' -# @enviroment.serpro_captcha_plugin_account= value -# assert_equal value, @enviroment.serpro_captcha_plugin['account'] -# end -# -# should 'serpro_captcha_plugin_account return the defined ldap account' do -# value = 'uid=sector,ou=Service,ou=corp,dc=company,dc=com,dc=br' -# @enviroment.serpro_captcha_plugin_account= value -# assert_equal value, @enviroment.serpro_captcha_plugin_account -# end -# -# should 'serpro_captcha_plugin_account_password= define the ldap acccount_password' do -# value = 'password' -# @enviroment.serpro_captcha_plugin_account_password= value -# assert_equal value, @enviroment.serpro_captcha_plugin['account_password'] -# end -# -# should 'serpro_captcha_plugin_account_password return the defined ldap account password' do -# value = 'password' -# @enviroment.serpro_captcha_plugin_account_password= value -# assert_equal value, @enviroment.serpro_captcha_plugin_account_password -# end -# -# should 'serpro_captcha_plugin_base_dn= define the ldap base_dn' do -# value = 'dc=company,dc=com,dc=br' -# @enviroment.serpro_captcha_plugin_base_dn= value -# assert_equal value, @enviroment.serpro_captcha_plugin['base_dn'] -# end -# -# should 'serpro_captcha_plugin_base_dn return the defined ldap base_dn' do -# value = 'dc=company,dc=com,dc=br' -# @enviroment.serpro_captcha_plugin_base_dn= value -# assert_equal value, @enviroment.serpro_captcha_plugin_base_dn -# end -# -# should 'serpro_captcha_plugin_attr_login= define the ldap attr_login' do -# value = 'uid' -# @enviroment.serpro_captcha_plugin_attr_login= value -# assert_equal value, @enviroment.serpro_captcha_plugin['attr_login'] -# end -# -# should 'serpro_captcha_plugin_attr_login return the defined ldap attr_login' do -# value = 'uid' -# @enviroment.serpro_captcha_plugin_attr_login= value -# assert_equal value, @enviroment.serpro_captcha_plugin_attr_login -# end -# -# should 'serpro_captcha_plugin_attr_fullname= define the ldap attr_fullname' do -# value = 'Noosfero System' -# @enviroment.serpro_captcha_plugin_attr_fullname= value -# assert_equal value, @enviroment.serpro_captcha_plugin['attr_fullname'] -# end -# -# should 'serpro_captcha_plugin_attr_fullname return the defined ldap attr_fullname' do -# value = 'uid' -# @enviroment.serpro_captcha_plugin_attr_fullname= value -# assert_equal value, @enviroment.serpro_captcha_plugin_attr_fullname -# end -# -# -# should 'serpro_captcha_plugin_attr_mail= define the ldap attr_mail' do -# value = 'test@noosfero.com' -# @enviroment.serpro_captcha_plugin_attr_mail= value -# assert_equal value, @enviroment.serpro_captcha_plugin['attr_mail'] -# end -# -# should 'serpro_captcha_plugin_attr_mail return the defined ldap attr_mail' do -# value = 'test@noosfero.com' -# @enviroment.serpro_captcha_plugin_attr_mail= value -# assert_equal value, @enviroment.serpro_captcha_plugin_attr_mail -# end -# -# should 'serpro_captcha_plugin_onthefly_register= define the ldap onthefly_register' do -# value = '1' -# @enviroment.serpro_captcha_plugin_onthefly_register= value -# assert @enviroment.serpro_captcha_plugin['onthefly_register'] -# end -# -# should 'serpro_captcha_plugin_onthefly_register return true if ldap onthefly_register variable is defined as true' do -# value = '1' -# @enviroment.serpro_captcha_plugin_onthefly_register= value -# assert @enviroment.serpro_captcha_plugin_onthefly_register -# end -# -# should 'serpro_captcha_plugin_onthefly_register return false if ldap onthefly_register variable is defined as false' do -# value = '0' -# @enviroment.serpro_captcha_plugin_onthefly_register= value -# refute @enviroment.serpro_captcha_plugin_onthefly_register -# end -# -# should 'serpro_captcha_plugin_filter= define the ldap filter' do -# value = 'test' -# @enviroment.serpro_captcha_plugin_filter= value -# assert_equal value, @enviroment.serpro_captcha_plugin['filter'] -# end -# -# should 'serpro_captcha_plugin_filter return the defined ldap filter' do -# value = 'test' -# @enviroment.serpro_captcha_plugin_filter= value -# assert_equal value, @enviroment.serpro_captcha_plugin_filter -# end -# -# should 'serpro_captcha_plugin_tls= define the ldap tls' do -# value = '1' -# @enviroment.serpro_captcha_plugin_tls= value -# assert @enviroment.serpro_captcha_plugin['tls'] -# end -# -# should 'tls return true if ldap tls variable is defined as true' do -# value = '1' -# @enviroment.serpro_captcha_plugin_tls= value -# assert @enviroment.serpro_captcha_plugin_tls -# end -# -# should 'tls return false if ldap tls variable is defined as false' do -# value = '0' -# @enviroment.serpro_captcha_plugin_tls= value -# refute @enviroment.serpro_captcha_plugin_tls -# end -# -# should 'validates presence of host' do -# @enviroment.serpro_captcha_plugin= {:port => 3000} -# @enviroment.valid? -# -# assert @enviroment.errors.include?(:serpro_captcha_plugin_host) -# -# @enviroment.serpro_captcha_plugin_host= "http://somehost.com" -# @enviroment.valid? -# refute @enviroment.errors.include?(:serpro_captcha_plugin_host) -# end -# -# should 'validates presence of host only if some ldap configuration is defined' do -# @enviroment.valid? -# refute @enviroment.errors.include?(:serpro_captcha_plugin_host) -# -# @enviroment.serpro_captcha_plugin= {:port => 3000} -# @enviroment.valid? -# assert @enviroment.errors.include?(:serpro_captcha_plugin_host) -# end -# -# end diff --git a/plugins/serpro_captcha/test/unit/serpro_captcha_verification_test.rb b/plugins/serpro_captcha/test/unit/serpro_captcha_verification_test.rb deleted file mode 100644 index efe4d4c..0000000 --- a/plugins/serpro_captcha/test/unit/serpro_captcha_verification_test.rb +++ /dev/null @@ -1,109 +0,0 @@ -require 'webmock' -include WebMock::API -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require_relative '../test_helper' - -class SerproCaptchaVerificationTest < ActiveSupport::TestCase - - def setup - @environment = Environment.default - @environment.enabled_plugins = ['SerproCaptchaPlugin'] - @environment.serpro_captcha_verify_uri="http://www.somecompany.com:443/validate" - @environment.serpro_captcha_client_id='323232' - @environment.save! - @captcha_token = "642646" - @captcha_text = "44641441" - @captcha_verification_body = "#{@environment.serpro_captcha_client_id}&#{@captcha_token}&#{@captcha_text}" - end - - def login_with_captcha - store = Noosfero::API::SessionStore.create("captcha") - ## Initialize the data for the session store - store.data = [] - ## Put it back in cache - store.store - { "private_token" => "#{store.private_token}" } - end - - def create_article(name) - person = fast_create(Person, :environment_id => @environment.id) - fast_create(Article, :profile_id => person.id, :name => name) - end - - should 'register a user when there are no enabled captcha pluging' do - @environment.enabled_plugins = [] - @environment.save! - Environment.default.enable('skip_new_user_email_confirmation') - params = {:login => "newuserapi", :password => "newuserapi", :password_confirmation => "newuserapi", :email => "newuserapi@email.com" } - post "/api/v1/register?#{params.to_query}" - assert_equal 201, last_response.status - json = JSON.parse(last_response.body) - assert User['newuserapi'].activated? - assert json['user']['private_token'].present? - end - - should 'not register a user if captcha fails' do - fail_captcha_text @environment.serpro_captcha_verify_uri, @captcha_verification_body - Environment.default.enable('skip_new_user_email_confirmation') - params = {:login => "newuserapi", :password => "newuserapi", :password_confirmation => "newuserapi", :email => "newuserapi@email.com", :txtToken_captcha_serpro_gov_br => @captcha_token, :captcha_text => @captcha_text} - post "/api/v1/register?#{params.to_query}" - assert_equal 403, last_response.status - json = JSON.parse(last_response.body) - assert_equal json["message"], _("Wrong captcha text, please try again") - end - - should 'verify_serpro_captcha' do - pass_captcha @environment.serpro_captcha_verify_uri, @captcha_verification_body - scv = SerproCaptchaVerification.new - assert scv.verify_serpro_captcha(@environment.serpro_captcha_client_id, @captcha_token, @captcha_text, @environment.serpro_captcha_verify_uri) - end - - should 'fail captcha if user has not filled Serpro\' captcha text' do - pass_captcha @environment.serpro_captcha_verify_uri, @captcha_verification_body - scv = SerproCaptchaVerification.new - hash = scv.verify_serpro_captcha(@environment.serpro_captcha_client_id, @captcha_token, nil, @environment.serpro_captcha_verify_uri) - assert hash[:user_message], _('Captcha text has not been filled') - end - - should 'fail captcha if Serpro\' captcha token has not been sent' do - pass_captcha @environment.serpro_captcha_verify_uri, @captcha_verification_body - scv = SerproCaptchaVerification.new - hash = scv.verify_serpro_captcha(@environment.serpro_captcha_client_id, nil, @captcha_text, @environment.serpro_captcha_verify_uri) - assert hash[:javascript_console_message], _("Missing Serpro's Captcha token") - end - - should 'fail captcha text' do - fail_captcha_text @environment.serpro_captcha_verify_uri, @captcha_verification_body - scv = SerproCaptchaVerification.new - hash = scv.verify_serpro_captcha(@environment.serpro_captcha_client_id, nil, @captcha_text, @environment.serpro_captcha_verify_uri) - assert hash[:javascript_console_message], _("Wrong captcha text, please try again") - end - - should 'not perform a vote without authentication' do - article = create_article('Article 1') - params = {} - params[:value] = 1 - - post "/api/v1/articles/#{article.id}/vote?#{params.to_query}" - json = JSON.parse(last_response.body) - assert_equal 401, last_response.status - end - - should 'perform a vote on an article identified by id' do - pass_captcha @environment.serpro_captcha_verify_uri, @captcha_verification_body - params = {} - params[:txtToken_captcha_serpro_gov_br]= @captcha_token - params[:captcha_text]= @captcha_text - post "/api/v1/login-captcha?#{params.to_query}" - json = JSON.parse(last_response.body) - article = create_article('Article 1') - params = {} - params[:private_token] = json['private_token'] - params[:value] = 1 - post "/api/v1/articles/#{article.id}/vote?#{params.to_query}" - json = JSON.parse(last_response.body) - assert_not_equal 401, last_response.status - assert_equal true, json['vote'] - end - -end diff --git a/plugins/serpro_captcha/views/serpro_captcha_plugin_admin/index.html.erb b/plugins/serpro_captcha/views/serpro_captcha_plugin_admin/index.html.erb deleted file mode 100644 index 07f01fd..0000000 --- a/plugins/serpro_captcha/views/serpro_captcha_plugin_admin/index.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -

<%= _("Serpro's Captcha Management") %>

- -<%= labelled_form_for(:environment, :url => {:action => 'update'}) do |f| %> - - - - - - - - - - - - - - -
<%= c_('Configuration') %><%= _('Value') %>
<%= _('Verify URI') %><%= text_field :environment, :serpro_captcha_verify_uri %>
<%= _('Client Id') %><%= text_field :environment, :serpro_captcha_client_id %>
- - -
- <% button_bar do %> - <%= submit_button('save', c_('Save changes')) %> - <%= button :back, _('Back to plugins administration panel'), :controller => 'plugins' %> - <% end %> -
- -<% end %> -- libgit2 0.21.2