java - Unit testing encrypt/decrypt with some salt located in different code bases -


first of shall mention have seen unit testing of encrypt/decrypt, , unit testing encryption , decryption in java.

i want protect library validating license. license contains information such maximum users , expiration time , on.

the problems encounter are:

  • the encryptor , decryptor in 2 different code bases. decryptor packaged library, encryptor not, hard have them both in same test suite!
  • a random salt used within encryptor, same input encryptor produces different output each time, again can not assertion on result.
  • for sake of purpose decryptor (to make harder inject class it) final class, , of methods private, except few package accessible entry points.

i don't want test jce, want test code does:

  • extracting salt encrypted license,
  • deciphers encrypted license,
  • deserializes output data structure containing license data,

shall create clone of the code, softer access constraints , test that? problem not testing real code run on client systems.

are there better solutions this?

from described don't see problem in testing them separately.

  • the encryptor , decryptor in 2 different code bases.

not issue if test them separately.

  • a random salt used within encryptor

you can inject mock random generator produce same results.

  • for sake of purpose decryptor final class, , of methods private

many ways test private methods can seen here

  • extracting salt encrypted license

all need encrypted license know salt of.

  • deciphers encrypted license

similarly, can use license know deciphers to.

  • deserializes output data structure containing license data,

not related , separate test of deserialization code.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -