【问题标题】:Ruby fixtures error with password column密码列的 Ruby 固定装置错误
【发布时间】:2010-06-02 08:46:44
【问题描述】:

我正在尝试为我的测试加载一个具有密码列(二进制数据类型)的夹具。我正在使用的工具使用 EzCrypto gem 在存储/检索密码之前对其进行加密和解密。现在,如果我的列是二进制的,我认为 rails 会自动将密码存储为加密 - 但我得到的只是:

1.

Error:
 test_is_working(FirstTest):
 RuntimeError: Failed to decode the field. Incorrect key?
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate 2.3.11/lib/will_paginate/finder.rb:170:in 'method_missing'
unit/first_test.rb:8:in setup

2.

Error:
test_sanity(FirstTest):
RuntimeError: Failed to decode the field. Incorrect key?
    unit/first_test.rb:8:in `setup'


    Fixture file looks like this:
    first_hussle:
        type: FirstAccount
        user: jsewq
        username: abc@mac.com
        password: 'abc123'

有什么线索吗?

【问题讨论】:

    标签: ruby-on-rails testing fixtures


    【解决方案1】:

    您需要使用 ezcrypto 对您的灯具中的密码进行加密。假设您的夹具是用于 users 表的,并且您已经定义了 user_crypto_provider.rb 文件/类。

    password: <%= UserCryptoProvider.encrypt('abc123') %>
    

    【讨论】:

      猜你喜欢
      • 2012-02-02
      • 2023-04-04
      • 2020-03-08
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 2010-10-20
      • 2016-04-30
      • 1970-01-01
      相关资源
      最近更新 更多