Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0187e706e1d1
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1a17b27439da
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on May 23, 2016

  1. 2
    Copy the full SHA
    eb49851 View commit details
  2. Copy the full SHA
    f22ef21 View commit details
  3. Copy the full SHA
    1a17b27 View commit details
111 changes: 26 additions & 85 deletions lib/ruby/truffle/jruby+truffle/gem_configurations/activemodel.yaml
Original file line number Diff line number Diff line change
@@ -37,104 +37,45 @@
end
end
require 'active_model'
require 'active_model/secure_password'
module ActiveModel
module SecurePassword
extend ActiveSupport::Concern
module InstanceMethodsOnActivation
def authenticate(unencrypted_password)
password_digest == unencrypted_password && self
require 'bcrypt'
module BCrypt
class Engine
def self.hash_secret(secret, salt, _ = nil)
if valid_secret?(secret)
if valid_salt?(salt)
Truffle::Gem::BCrypt.hashpw(secret.to_s, salt.to_s)
else
raise Errors::InvalidSalt.new("invalid salt")
end
else
raise Errors::InvalidSecret.new("invalid secret")
end
end
attr_reader :password
def password=(unencrypted_password)
self.password_digest = unencrypted_password
def self.generate_salt(cost = self.cost)
cost = cost.to_i
if cost > 0
if cost < MIN_COST
cost = MIN_COST
end
Truffle::Gem::BCrypt.gensalt(cost)
else
raise Errors::InvalidCost.new("cost must be numeric and > 0")
end
end
end
end
bcrypt.rb: |
puts 'bcrypt stubbed'
module BCrypt
module Password
def self.create(password, *args)
password
end
end
module Engine
MIN_COST = nil
end
end
java.rb: nil
bcrypt_ext.rb: nil
bundler.rb: "module Bundler; def self.setup; end; end"
# mock method_source gem
# method_source.rb: nil
exclude_tests.rb: |
failures = { AttributeMethodsTest: [:"test_#define_attribute_methods_generates_attribute_methods",
:"test_#define_attribute_methods_generates_attribute_methods_with_spaces_in_their_names",
:"test_#define_attribute_methods_works_passing_multiple_arguments"],
SecurePasswordTest: [:test_Password_digest_cost_can_be_set_to_bcrypt_min_cost_to_speed_up_tests,
:test_Password_digest_cost_defaults_to_bcrypt_default_cost_when_min_cost_is_false,
:test_Password_digest_cost_honors_bcrypt_cost_attribute_when_min_cost_is_false,
:test_create_a_new_user_with_validation_and_a_blank_password_confirmation,
:test_create_a_new_user_with_validation_and_a_spaces_only_password,
:test_create_a_new_user_with_validation_and_an_incorrect_password_confirmation,
:test_create_a_new_user_with_validation_and_password_length_greater_than_72,
:test_setting_a_blank_password_should_not_change_an_existing_password,
:test_updating_an_existing_user_with_validation_and_a_blank_password,
:test_updating_an_existing_user_with_validation_and_a_blank_password_and_password_confirmation,
:test_updating_an_existing_user_with_validation_and_a_blank_password_confirmation,
:test_updating_an_existing_user_with_validation_and_a_spaces_only_password,
:test_updating_an_existing_user_with_validation_and_an_incorrect_password_confirmation,
:test_updating_an_existing_user_with_validation_and_password_length_greater_than_72],
I18nValidationTest: [:test_validates_acceptance_of_finds_custom_model_key_translation_when_accepted,
:test_validates_acceptance_of_finds_custom_model_key_translation_with_interpolation_when_accepted,
:test_validates_acceptance_of_finds_global_default_key_translation_when_accepted,
:test_validates_confirmation_of_finds_custom_model_key_translation_when_confirmation,
:test_validates_confirmation_of_finds_custom_model_key_translation_with_interpolation_when_confirmation,
:test_validates_confirmation_of_finds_global_default_key_translation_when_confirmation,
:test_validates_exclusion_of_finds_custom_model_key_translation_when_exclusion,
:test_validates_exclusion_of_finds_custom_model_key_translation_with_interpolation_when_exclusion,
:test_validates_exclusion_of_finds_global_default_key_translation_when_exclusion,
:test_validates_format_of_finds_custom_model_key_translation_when_invalid,
:test_validates_format_of_finds_custom_model_key_translation_with_interpolation_when_invalid,
:test_validates_format_of_finds_global_default_key_translation_when_invalid,
:test_validates_inclusion_of_finds_custom_model_key_translation_when_inclusion,
:test_validates_inclusion_of_finds_custom_model_key_translation_with_interpolation_when_inclusion,
:test_validates_inclusion_of_finds_global_default_key_translation_when_inclusion,
:test_validates_length_of_finds_custom_model_key_translation_when_too_long,
:test_validates_length_of_finds_custom_model_key_translation_when_too_short,
:test_validates_length_of_finds_custom_model_key_translation_when_wrong_length,
:test_validates_length_of_finds_custom_model_key_translation_with_interpolation_when_too_long,
:test_validates_length_of_finds_custom_model_key_translation_with_interpolation_when_too_short,
:test_validates_length_of_finds_custom_model_key_translation_with_interpolation_when_wrong_length,
:test_validates_length_of_finds_global_default_key_translation_when_too_long,
:test_validates_length_of_finds_global_default_key_translation_when_too_short,
:test_validates_length_of_finds_global_default_key_translation_when_wrong_length,
:test_validates_numericality_of_finds_custom_model_key_translation_when_less_than,
:test_validates_numericality_of_finds_custom_model_key_translation_when_not_a_number,
:test_validates_numericality_of_finds_custom_model_key_translation_when_not_an_integer,
:test_validates_numericality_of_finds_custom_model_key_translation_when_odd,
:test_validates_numericality_of_finds_custom_model_key_translation_with_interpolation_when_less_than,
:test_validates_numericality_of_finds_custom_model_key_translation_with_interpolation_when_not_a_number,
:test_validates_numericality_of_finds_custom_model_key_translation_with_interpolation_when_not_an_integer,
:test_validates_numericality_of_finds_custom_model_key_translation_with_interpolation_when_odd,
:test_validates_numericality_of_finds_global_default_key_translation_when_less_than,
:test_validates_numericality_of_finds_global_default_key_translation_when_not_a_number,
:test_validates_numericality_of_finds_global_default_key_translation_when_not_an_integer,
:test_validates_numericality_of_finds_global_default_key_translation_when_odd,
:test_validates_presence_of_finds_custom_model_key_translation_when_blank,
:test_validates_presence_of_finds_custom_model_key_translation_with_interpolation_when_blank,
:test_validates_presence_of_finds_global_default_key_translation_when_blank],
NumericalityValidationTest: [:test_validates_numericality_with_equal_to] }
:"test_#define_attribute_methods_works_passing_multiple_arguments"] }
Truffle.exclude_rspec_examples failures
5 changes: 5 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@
import org.jruby.truffle.debug.TruffleDebugNodesFactory;
import org.jruby.truffle.extra.AttachmentsInternalNodesFactory;
import org.jruby.truffle.extra.TruffleGraalNodesFactory;
import org.jruby.truffle.gem.bcrypt.BCryptNodesFactory;
import org.jruby.truffle.interop.CExtNodesFactory;
import org.jruby.truffle.interop.InteropNodesFactory;
import org.jruby.truffle.language.RubyGuards;
@@ -605,6 +606,9 @@ public CoreLibrary(RubyContext context) {
bigDecimalClass = defineClass(truffleModule, numericClass, "BigDecimal");
Layouts.CLASS.setInstanceFactoryUnsafe(bigDecimalClass, Layouts.BIG_DECIMAL.createBigDecimalShape(bigDecimalClass, bigDecimalClass));

final DynamicObject gem = defineModule(truffleModule, "Gem");
defineModule(gem, "BCrypt");

// Rubinius

rubiniusModule = defineModule("Rubinius");
@@ -753,6 +757,7 @@ public void addCoreMethods() {
coreMethodNodeManager.addCoreMethodNodes(TruffleProcessNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(TruffleDebugNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(TruffleBindingNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(BCryptNodesFactory.getFactories());

coreMethodNodeManager.allMethodInstalled();

Original file line number Diff line number Diff line change
@@ -92,14 +92,18 @@ public IOPrimitiveArrayArgumentsNode(RubyContext context, SourceSection sourceSe
super(context, sourceSection);
}

protected int ensureSuccessful(int result) {
protected int ensureSuccessful(int result, int errno) {
assert result >= -1;
if (result == -1) {
errorProfile.enter();
throw new RaiseException(coreExceptions().errnoError(posix().errno(), this));
throw new RaiseException(coreExceptions().errnoError(errno, this));
}
return result;
}

protected int ensureSuccessful(int result) {
return ensureSuccessful(result, posix().errno());
}
}

private static int STDOUT = 1;
@@ -332,32 +336,31 @@ public IOReopenPathPrimitiveNode(RubyContext context, SourceSection sourceSectio
}

@TruffleBoundary
public void performReopenPath(DynamicObject file, DynamicObject path, int mode) {
int fd = Layouts.IO.getDescriptor(file);
final String pathString = StringOperations.getString(getContext(), path);
public void performReopenPath(DynamicObject self, DynamicObject path, int mode) {
int fdSelf = Layouts.IO.getDescriptor(self);
final String targetPathString = StringOperations.getString(getContext(), path);

int otherFd = ensureSuccessful(posix().open(pathString, mode, 666));
int fdTarget = ensureSuccessful(posix().open(targetPathString, mode, 666));

final int result = posix().dup2(otherFd, fd);
final int result = posix().dup2(fdTarget, fdSelf);
if (result == -1) {
final int errno = posix().errno();
if (errno == Errno.EBADF.intValue()) {
Layouts.IO.setDescriptor(file, otherFd);
fd = otherFd;
Layouts.IO.setDescriptor(self, fdTarget);
fdSelf = fdTarget;
} else {
if (otherFd > 0) {
ensureSuccessful(posix().close(otherFd));
if (fdTarget > 0) {
ensureSuccessful(posix().close(fdTarget));
}
throw new RaiseException(coreExceptions().errnoError(errno, this));
ensureSuccessful(result, errno);
}

} else {
ensureSuccessful(posix().close(otherFd));
ensureSuccessful(posix().close(fdTarget));
}


final int newMode = ensureSuccessful(posix().fcntl(fd, Fcntl.F_GETFL));
Layouts.IO.setMode(file, newMode);
final int newSelfMode = ensureSuccessful(posix().fcntl(fdSelf, Fcntl.F_GETFL));
Layouts.IO.setMode(self, newSelfMode);
}

@Specialization(guards = "isRubyString(path)")
Loading