Handle nil and empty string cleanly #35

Merged
merged 1 commit into from Apr 11, 2013

Conversation

Projects
None yet
2 participants
@Capncavedan
Contributor

Capncavedan commented Apr 11, 2013

Updates AES encryptor #encrypt and #decrypt to return value as-is when value is nil or the empty string.

lib/crypt_keeper/provider/aes.rb
@@ -29,8 +29,9 @@ def initialize(options = {})
# Public: Encrypt a string
#
- # Returns a string
+ # Returns nil if passed nil, or a string; empty-string is returned as-is

This comment has been minimized.

@jmazzi

jmazzi Apr 11, 2013

Owner

How about adding a note like nil and empty strings are not encryptable with AES. When they are encountered, the orignal plaintext is returned. Then Returns the original value or encrypted string

@jmazzi

jmazzi Apr 11, 2013

Owner

How about adding a note like nil and empty strings are not encryptable with AES. When they are encountered, the orignal plaintext is returned. Then Returns the original value or encrypted string

@jmazzi

This comment has been minimized.

Show comment
Hide comment
@jmazzi

jmazzi Apr 11, 2013

Owner

Looks good! Just a quick doc change needed.

Owner

jmazzi commented Apr 11, 2013

Looks good! Just a quick doc change needed.

@Capncavedan

This comment has been minimized.

Show comment
Hide comment
@Capncavedan

Capncavedan Apr 11, 2013

Contributor

@jmazzi you got it!

Contributor

Capncavedan commented Apr 11, 2013

@jmazzi you got it!

spec/provider/aes_spec.rb
+ subject.encrypt ''
+ end
+
+ specify { encrypted.should == '' }
end

This comment has been minimized.

@jmazzi

jmazzi Apr 11, 2013

Owner

You can remove the non-empty context, it's already covered under #encrypt

@jmazzi

jmazzi Apr 11, 2013

Owner

You can remove the non-empty context, it's already covered under #encrypt

This comment has been minimized.

@jmazzi

jmazzi Apr 11, 2013

Owner

What i mean is, they don't have to be under that context. Just leave them top level :)

@jmazzi

jmazzi Apr 11, 2013

Owner

What i mean is, they don't have to be under that context. Just leave them top level :)

spec/provider/aes_spec.rb
+ subject.decrypt "MC41MDk5MjI2NjgxMDI1MDI2OmNyeXB0X2tlZXBlcjpPI/8dCqWXDMVj7Jqs\nuwf/\n"
+ end
+
+ specify { decrypted.should == 'string' }

This comment has been minimized.

@jmazzi

jmazzi Apr 11, 2013

Owner

This is already covered as well.

@jmazzi

jmazzi Apr 11, 2013

Owner

This is already covered as well.

@Capncavedan

This comment has been minimized.

Show comment
Hide comment
@Capncavedan

Capncavedan Apr 11, 2013

Contributor

Sure thing

Contributor

Capncavedan commented Apr 11, 2013

Sure thing

spec/provider/aes_spec.rb
end
+

This comment has been minimized.

@jmazzi

jmazzi Apr 11, 2013

Owner

Can you remove this new line? :trollface:

@jmazzi

jmazzi Apr 11, 2013

Owner

Can you remove this new line? :trollface:

This comment has been minimized.

@jmazzi

jmazzi Apr 11, 2013

Owner

I meant the one on line 65 :O

@jmazzi

jmazzi Apr 11, 2013

Owner

I meant the one on line 65 :O

@jmazzi

This comment has been minimized.

Show comment
Hide comment
@jmazzi

jmazzi Apr 11, 2013

Owner

After that new line is removed, squash it and it's good to merge

Owner

jmazzi commented Apr 11, 2013

After that new line is removed, squash it and it's good to merge

@Capncavedan

This comment has been minimized.

Show comment
Hide comment
@Capncavedan

Capncavedan Apr 11, 2013

Contributor

Un-newlined and squashed!

Contributor

Capncavedan commented Apr 11, 2013

Un-newlined and squashed!

jmazzi added a commit that referenced this pull request Apr 11, 2013

Merge pull request #35 from MerchantsBonding/feature-handle-nil-and-e…
…mpty-string-cleanly

Handle nil and empty string cleanly

@jmazzi jmazzi merged commit 7dff402 into jmazzi:master Apr 11, 2013

1 check was pending

default The Travis build is in progress
Details

@Capncavedan Capncavedan deleted the MerchantsBonding:feature-handle-nil-and-empty-string-cleanly branch Apr 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment