From 21e3a1e35076c174139c31ec19981bdd6b4eb3d2 Mon Sep 17 00:00:00 2001 From: Vyacheslav Gudkov Date: Thu, 9 Nov 2017 16:46:53 +0300 Subject: [PATCH 01/14] * Implemented new key_for_local_did call * Added tests for key_for_local_did * Added python and java wrappers for key_for_local_did and corresponded tests Signed-off-by: Vyacheslav Gudkov --- libindy/include/indy_signus.h | 69 ++++++++++++++++++ libindy/src/api/signus.rs | 61 ++++++++++++++++ libindy/src/commands/signus.rs | 38 ++++++++++ libindy/tests/signus.rs | 66 +++++++++++++++++ libindy/tests/utils/callback.rs | 28 +++++++- libindy/tests/utils/signus.rs | 24 +++++++ .../org/hyperledger/indy/sdk/LibIndy.java | 1 + .../hyperledger/indy/sdk/signus/Signus.java | 70 ++++++++++++++++++- .../indy/sdk/signus/KeyForLocalDidTest.java | 40 +++++++++++ wrappers/python/indy/signus.py | 61 +++++++++++++++- .../tests/signus/test_key_for_local_did.py | 37 ++++++++++ 11 files changed, 488 insertions(+), 7 deletions(-) create mode 100644 wrappers/java/src/test/java/org/hyperledger/indy/sdk/signus/KeyForLocalDidTest.java create mode 100644 wrappers/python/tests/signus/test_key_for_local_did.py diff --git a/libindy/include/indy_signus.h b/libindy/include/indy_signus.h index 346afd0eda..176655b52d 100644 --- a/libindy/include/indy_signus.h +++ b/libindy/include/indy_signus.h @@ -124,6 +124,37 @@ extern "C" { indy_error_t err) ); + /// Returns ver key (key id) for the given DID. + /// + /// This call follow the idea that we resolve information about their DID from + /// the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter + /// that is used for checking the freshness of cached pool value. + /// + /// Note if you don't want to resolve their DID info from the ledger you can use + /// indy_key_for_local_did call instead that will look only to local wallet and skip + /// freshness checking + /// + /// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + /// As result we can use returned ver key in all generic crypto and messaging functions. + /// Note that this function looks to wallet and if no wallet record can lookup ledger. + /// + /// #Params + /// command_handle: Command handle to map callback to caller context. + /// wallet_handle: Wallet handle (created by open_wallet). + /// did - The DID to resolve key. + /// cb: Callback that takes command result as parameter. + /// + /// #Returns + /// Error Code + /// cb: + /// - xcommand_handle: Command handle to map callback to caller context. + /// - err: Error code. + /// - key - The DIDs ver key (key id). + /// + /// #Errors + /// Common* + /// Wallet* + /// Crypto* extern indy_error_t indy_key_for_did(indy_handle_t command_handle, indy_handle_t pool_handle, indy_handle_t wallet_handle, @@ -134,6 +165,44 @@ extern "C" { const char *const key) ); + //// Returns ver key (key id) for the given DID. + /// + /// This call looks data stored in the local wallet only and skips freshness checking. + /// + /// Note if you want to get fresh data from the ledger you can use indy_key_for_did call + /// instead. + /// + /// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + /// As result we can use returned ver key in all generic crypto and messaging functions. + /// Note that this function looks to wallet and if no wallet record can lookup ledger. + /// + /// #Params + /// command_handle: Command handle to map callback to caller context. + /// wallet_handle: Wallet handle (created by open_wallet). + /// did - The DID to resolve key. + /// cb: Callback that takes command result as parameter. + /// + /// #Returns + /// Error Code + /// cb: + /// - xcommand_handle: Command handle to map callback to caller context. + /// - err: Error code. + /// - key - The DIDs ver key (key id). + /// + /// #Errors + /// Common* + /// Wallet* + /// Crypto* + extern indy_error_t indy_key_for_local_did(indy_handle_t command_handle, + indy_handle_t pool_handle, + indy_handle_t wallet_handle, + const char *const did, + + void (*cb)(indy_handle_t command_handle, + indy_error_t err, + const char *const key) + ); + extern indy_error_t indy_set_endpoint_for_did(indy_handle_t command_handle, indy_handle_t wallet_handle, const char *const did, diff --git a/libindy/src/api/signus.rs b/libindy/src/api/signus.rs index 1eb370301e..1bad0f8151 100644 --- a/libindy/src/api/signus.rs +++ b/libindy/src/api/signus.rs @@ -187,6 +187,15 @@ pub extern fn indy_store_their_did(command_handle: i32, } /// Returns ver key (key id) for the given DID. +/// +/// This call follow the idea that we resolve information about their DID from +/// the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter +/// that is used for checking the freshness of cached pool value. +/// +/// Note if you don't want to resolve their DID info from the ledger you can use +/// indy_key_for_local_did call instead that will look only to local wallet and skip +/// freshness checking. +/// /// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. /// As result we can use returned ver key in all generic crypto and messaging functions. /// Note that this function looks to wallet and if no wallet record can lookup ledger. @@ -234,6 +243,58 @@ pub extern fn indy_key_for_did(command_handle: i32, result_to_err_code!(result) } +/// Returns ver key (key id) for the given DID. +/// +/// This call looks data stored in the local wallet only and skips freshness checking. +/// +/// Note if you want to get fresh data from the ledger you can use indy_key_for_did call +/// instead. +/// +/// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. +/// As result we can use returned ver key in all generic crypto and messaging functions. +/// Note that this function looks to wallet and if no wallet record can lookup ledger. +/// +/// #Params +/// command_handle: Command handle to map callback to caller context. +/// wallet_handle: Wallet handle (created by open_wallet). +/// did - The DID to resolve key. +/// cb: Callback that takes command result as parameter. +/// +/// #Returns +/// Error Code +/// cb: +/// - xcommand_handle: Command handle to map callback to caller context. +/// - err: Error code. +/// - key - The DIDs ver key (key id). +/// +/// #Errors +/// Common* +/// Wallet* +/// Crypto* +#[no_mangle] +pub extern fn indy_key_for_local_did(command_handle: i32, + wallet_handle: i32, + did: *const c_char, + cb: Option) -> ErrorCode { + check_useful_c_str!(did, ErrorCode::CommonInvalidParam3); + check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam4); + + let result = CommandExecutor::instance() + .send(Command::Signus(SignusCommand::KeyForLocalDid( + wallet_handle, + did, + Box::new(move |result| { + let (err, key) = result_to_err_code_1!(result, String::new()); + let key = CStringUtils::string_to_cstring(key); + cb(command_handle, err, key.as_ptr()) + }) + ))); + + result_to_err_code!(result) +} + /// Returns endpoint information for the given DID. /// /// #Params diff --git a/libindy/src/commands/signus.rs b/libindy/src/commands/signus.rs index 396c1e6588..a391ac5780 100644 --- a/libindy/src/commands/signus.rs +++ b/libindy/src/commands/signus.rs @@ -82,6 +82,10 @@ pub enum SignusCommand { i32, // wallet handle String, // did (my or their) Box) + Send>), + KeyForLocalDid( + i32, // wallet handle + String, // did (my or their) + Box) + Send>), SetEndpointForDid( i32, // wallet handle String, // did @@ -199,6 +203,10 @@ impl SignusCommandExecutor { info!("KeyForDid command received"); self.key_for_did(pool_handle, wallet_handle, did, cb); } + SignusCommand::KeyForLocalDid(wallet_handle, did, cb) => { + info!("KeyForLocalDid command received"); + cb(self.key_for_local_did(wallet_handle, did)); + } SignusCommand::SetEndpointForDid(wallet_handle, did, address, transport_key, cb) => { info!("SetEndpointForDid command received"); cb(self.set_endpoint_for_did(wallet_handle, did, address, transport_key)); @@ -460,6 +468,25 @@ impl SignusCommandExecutor { cb(Ok(res)) } + fn key_for_local_did(&self, + wallet_handle: i32, + did: String) -> Result { + self.signus_service.validate_did(&did)?; + + // Look to my did + match self._wallet_get_my_did(wallet_handle, &did) { + Ok(my_did) => return Ok(my_did.verkey), + Err(IndyError::WalletError(WalletError::NotFound(_))) => {} + Err(err) => return Err(err) + }; + + // look to their did + let their_did = self._wallet_get_local_their_did(wallet_handle, &did)?; + + let res = their_did.verkey; + Ok(res) + } + fn set_endpoint_for_did(&self, wallet_handle: i32, did: String, @@ -735,6 +762,17 @@ impl SignusCommandExecutor { Ok(res) } + fn _wallet_get_local_their_did(&self, wallet_handle: i32, their_did: &str) -> Result { + let their_did_json = self.wallet_service.get(wallet_handle, &format!("their_did::{}", their_did))?; + + let res = Did::from_json(&their_did_json) + .map_err(map_err_trace!()) + .map_err(|err| + CommonError::InvalidState( + format!("Can't deserialize their Did: {}", err.description())))?; + Ok(res) + } + fn _wallet_set_my_temporary_did(&self, wallet_handle: i32, my_temporary_did: &Did) -> Result<(), IndyError> { let my_temporary_did_json = Did::to_json(my_temporary_did) .map_err(map_err_trace!()) diff --git a/libindy/tests/signus.rs b/libindy/tests/signus.rs index 834589c90a..d2ee412a3f 100644 --- a/libindy/tests/signus.rs +++ b/libindy/tests/signus.rs @@ -156,6 +156,72 @@ mod high_cases { } } + mod key_for_local_did { + use super::*; + + #[test] + fn indy_key_for_local_did_works_for_my_did() { + TestUtils::cleanup_storage(); + + let wallet_handle = WalletUtils::create_and_open_wallet(POOL, None).unwrap(); + + let (did, verkey) = SignusUtils::create_and_store_my_did(wallet_handle, Some(MY1_SEED)).unwrap(); + + let received_verkey = SignusUtils::key_for_local_did(wallet_handle, &did).unwrap(); + assert_eq!(verkey, received_verkey); + + WalletUtils::close_wallet(wallet_handle).unwrap(); + + TestUtils::cleanup_storage(); + } + + #[test] + fn indy_key_for_local_did_works_for_their_did() { + TestUtils::cleanup_storage(); + + let wallet_handle = WalletUtils::create_and_open_wallet(POOL, None).unwrap(); + + SignusUtils::store_their_did_from_parts(wallet_handle, DID, VERKEY).unwrap(); + + let received_verkey = SignusUtils::key_for_local_did(wallet_handle, DID).unwrap(); + assert_eq!(VERKEY, received_verkey); + + WalletUtils::close_wallet(wallet_handle).unwrap(); + + TestUtils::cleanup_storage(); + } + + #[test] + fn indy_key_for_local_did_works_for_unknown_did() { + TestUtils::cleanup_storage(); + + let wallet_handle = WalletUtils::create_and_open_wallet(POOL, None).unwrap(); + + let res = SignusUtils::key_for_local_did(wallet_handle, DID); + assert_eq!(ErrorCode::WalletNotFoundError, res.unwrap_err()); + + WalletUtils::close_wallet(wallet_handle).unwrap(); + + TestUtils::cleanup_storage(); + } + + #[test] + fn indy_key_for_local_did_works_for_invalid_wallet_handle() { + TestUtils::cleanup_storage(); + + let wallet_handle = WalletUtils::create_and_open_wallet(POOL, None).unwrap(); + + let (did, _) = SignusUtils::create_and_store_my_did(wallet_handle, Some(MY1_SEED)).unwrap(); + + let res = SignusUtils::key_for_local_did(wallet_handle + 1, &did); + assert_eq!(ErrorCode::WalletInvalidHandle, res.unwrap_err()); + + WalletUtils::close_wallet(wallet_handle).unwrap(); + + TestUtils::cleanup_storage(); + } + } + mod set_endpoint_for_did { use super::*; diff --git a/libindy/tests/utils/callback.rs b/libindy/tests/utils/callback.rs index b7287e6c4c..786edda1e5 100644 --- a/libindy/tests/utils/callback.rs +++ b/libindy/tests/utils/callback.rs @@ -513,9 +513,9 @@ impl CallbackUtils { } pub fn closure_to_crypto_verify_cb(closure: Box) -> (i32, - Option) { + Option) { lazy_static! { static ref CRYPTO_VERIFY_CALLBACKS: Mutex < HashMap < i32, Box < FnMut(ErrorCode, bool) + Send > >> = Default::default(); } @@ -1302,6 +1302,28 @@ impl CallbackUtils { (command_handle, Some(key_for_did_callback)) } + pub fn closure_to_key_for_local_did_cb(closure: Box) -> (i32, + Option) { + lazy_static! { + static ref KEY_FOR_LOCAL_DID_CALLBACKS: Mutex < HashMap < i32, Box < FnMut(ErrorCode, String) + Send > >> = Default::default(); + } + + extern "C" fn key_for_local_did_callback(command_handle: i32, err: ErrorCode, verkey: *const c_char) { + let mut callbacks = KEY_FOR_LOCAL_DID_CALLBACKS.lock().unwrap(); + let mut cb = callbacks.remove(&command_handle).unwrap(); + let verkey = unsafe { CStr::from_ptr(verkey).to_str().unwrap().to_string() }; + cb(err, verkey) + } + + let mut callbacks = KEY_FOR_LOCAL_DID_CALLBACKS.lock().unwrap(); + let command_handle = (COMMAND_HANDLE_COUNTER.fetch_add(1, Ordering::SeqCst) + 1) as i32; + callbacks.insert(command_handle, closure); + + (command_handle, Some(key_for_local_did_callback)) + } + pub fn closure_to_set_endpoint_for_did_cb(closure: Box) -> (i32, Option) { diff --git a/libindy/tests/utils/signus.rs b/libindy/tests/utils/signus.rs index a135508ff6..0761765755 100644 --- a/libindy/tests/utils/signus.rs +++ b/libindy/tests/utils/signus.rs @@ -431,6 +431,30 @@ impl SignusUtils { Ok(verkey) } + pub fn key_for_local_did(wallet_handle: i32, did: &str) -> Result { + let (sender, receiver) = channel(); + let cb = Box::new(move |err, verkey| { + sender.send((err, verkey)).unwrap(); + }); + let (command_handle, callback) = CallbackUtils::closure_to_key_for_local_did_cb(cb); + + let did = CString::new(did).unwrap(); + + let err = indy_key_for_local_did(command_handle, + wallet_handle, + did.as_ptr(), + callback); + + if err != ErrorCode::Success { + return Err(err); + } + let (err, verkey) = receiver.recv_timeout(TimeoutUtils::long_timeout()).unwrap(); + if err != ErrorCode::Success { + return Err(err); + } + Ok(verkey) + } + pub fn set_endpoint_for_did(wallet_handle: i32, did: &str, address: &str, transport_key: &str) -> Result<(), ErrorCode> { let (sender, receiver) = channel(); let cb = Box::new(move |err| { diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java index 0eea4faf90..175cf192a0 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java @@ -66,6 +66,7 @@ public interface API extends Library { public int indy_encrypt_sealed(int command_handle, int wallet_handle, int pool_handle, String did, byte[] message_raw, int message_len, Callback cb); public int indy_decrypt_sealed(int command_handle, int wallet_handle, String did, byte[] encrypted_msg_raw, int encrypted_msg_len, Callback cb); public int indy_key_for_did(int command_handle, int pool_handle, int wallet_handle, String did, Callback cb); + public int indy_key_for_local_did(int command_handle, int wallet_handle, String did, Callback cb); public int indy_set_endpoint_for_did(int command_handle, int wallet_handle, String did, String address, String transportKey, Callback cb); public int indy_get_endpoint_for_did(int command_handle, int wallet_handle, int pool_handle, String did, Callback cb); public int indy_set_did_metadata(int command_handle, int wallet_handle, String did, String metadata, Callback cb); diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java index bb08df5cd5..66c888e284 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java @@ -219,6 +219,22 @@ public void callback(int xcommand_handle, int err, String key) { } }; + /** + * Callback used when keyForLocalDid completes. + */ + private static Callback keyForLocalDidCb = new Callback() { + + @SuppressWarnings({"unused", "unchecked"}) + public void callback(int xcommand_handle, int err, String key) { + + CompletableFuture future = (CompletableFuture) removeFuture(xcommand_handle); + if (! checkCallback(future, err)) return; + + String result = key; + future.complete(result); + } + }; + /** * Callback used when setEndpointForDid completes. */ @@ -660,7 +676,19 @@ public static CompletableFuture decryptSealed( } /** - * Retrieves the key for the giving did in the wallet or pool. + * Returns ver key (key id) for the given DID. + * + * This call follow the idea that we resolve information about their DID from + * the ledger with cache in the local wallet. The openWallet call has freshness parameter + * that is used for checking the freshness of cached pool value. + * + * Note if you don't want to resolve their DID info from the ledger you can use + * keyForLocalDid call instead that will look only to local wallet and skip + * freshness checking. + * + * Note that createAndStoreMyDid makes similar wallet record as createKey. + * As result we can use returned ver key in all generic crypto and messaging functions. + * Note that this function looks to wallet and if no wallet record can lookup ledger. * * @param pool The pool. * @param wallet The wallet. @@ -695,6 +723,46 @@ public static CompletableFuture keyForDid( return future; } + /** + * Returns ver key (key id) for the given DID. + * + * This call looks data stored in the local wallet only and skips freshness checking. + * + * Note if you want to get fresh data from the ledger you can use indy_key_for_did call + * instead. + * + * Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + * As result we can use returned ver key in all generic crypto and messaging functions. + * Note that this function looks to wallet and if no wallet record can lookup ledger. + * + * @param wallet The wallet. + * @param did + * @return A future resolving to a verkey + * @throws IndyException Thrown if an error occurs when calling the underlying SDK. + */ + public static CompletableFuture keyForLocalDid( + Wallet wallet, + String did) throws IndyException { + + ParamGuard.notNull(wallet, "wallet"); + ParamGuard.notNullOrWhiteSpace(did, "did"); + + CompletableFuture future = new CompletableFuture(); + int commandHandle = addFuture(future); + + int walletHandle = wallet.getWalletHandle(); + + int result = LibIndy.api.indy_key_for_local_did( + commandHandle, + walletHandle, + did, + keyForLocalDidCb); + + checkResult(result); + + return future; + } + /** * @param wallet The wallet. * @param did The encrypted Did. diff --git a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/signus/KeyForLocalDidTest.java b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/signus/KeyForLocalDidTest.java new file mode 100644 index 0000000000..5e9a4396b6 --- /dev/null +++ b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/signus/KeyForLocalDidTest.java @@ -0,0 +1,40 @@ +package org.hyperledger.indy.sdk.signus; + +import org.hyperledger.indy.sdk.IndyIntegrationTestWithSingleWallet; +import org.hyperledger.indy.sdk.wallet.WalletValueNotFoundException; +import org.junit.Test; + +import java.util.concurrent.ExecutionException; + +import static org.hamcrest.CoreMatchers.isA; +import static org.junit.Assert.assertEquals; + + +public class KeyForLocalDidTest extends IndyIntegrationTestWithSingleWallet { + + @Test + public void testKeyForLocalDidWorksForMyDid() throws Exception { + SignusResults.CreateAndStoreMyDidResult result = Signus.createAndStoreMyDid(wallet, "{}").get(); + String did = result.getDid(); + String key = result.getVerkey(); + + String receivedKey = Signus.keyForLocalDid(wallet, did).get(); + assertEquals(key, receivedKey); + } + + @Test + public void testKeyForLocalDidWorksForTheirDid() throws Exception { + Signus.storeTheirDid(wallet, String.format(IDENTITY_JSON_TEMPLATE, DID_MY1, VERKEY_MY1)).get(); + + String receivedKey = Signus.keyForLocalDid(wallet, DID_MY1).get(); + assertEquals(VERKEY_MY1, receivedKey); + } + + @Test + public void testKeyForDidWorksForNoKey() throws Exception { + thrown.expect(ExecutionException.class); + thrown.expectCause(isA(WalletValueNotFoundException.class)); + + Signus.keyForLocalDid(wallet, DID_MY2).get(); + } +} \ No newline at end of file diff --git a/wrappers/python/indy/signus.py b/wrappers/python/indy/signus.py index 6d4f4f8a0b..e5db1cb269 100644 --- a/wrappers/python/indy/signus.py +++ b/wrappers/python/indy/signus.py @@ -20,7 +20,8 @@ async def create_and_store_my_did(wallet_handle: int, :param did_json: Identity information as json. Example: { "did": string, (optional; - if not provided and cid param is false then the first 16 bit of the verkey will be used as a new DID; + if not provided and cid param is false then the first 16 bit of the verkey will be + used as a new DID; if not provided and cid is true then the full verkey will be used as a new DID; if provided, then keys will be replaced - key rotation use case) "seed": string, (optional; if not provide then a random one will be created) @@ -577,9 +578,21 @@ async def key_for_did(pool_handle: int, wallet_handle: int, did: str) -> str: """ - Retrieves the meta information for the giving key in the wallet. + Returns ver key (key id) for the given DID. + + This call follow the idea that we resolve information about their DID from + the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter + that is used for checking the freshness of cached pool value. + + Note if you don't want to resolve their DID info from the ledger you can use + indy_key_for_local_did call instead that will look only to local wallet and skip + freshness checking. + + Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + As result we can use returned ver key in all generic crypto and messaging functions. + Note that this function looks to wallet and if no wallet record can lookup ledger. - :param pool_handle: Pool handle (created by open)pool). + :param pool_handle: Pool handle (created by open_pool). :param wallet_handle: Wallet handle (created by open_wallet). :param did: :return: key: @@ -611,6 +624,48 @@ async def key_for_did(pool_handle: int, return res +async def key_for_local_did(wallet_handle: int, + did: str) -> str: + """ + Returns ver key (key id) for the given DID. + + This call looks data stored in the local wallet only and skips freshness checking. + + Note if you want to get fresh data from the ledger you can use indy_key_for_did call + instead. + + Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + As result we can use returned ver key in all generic crypto and messaging functions. + Note that this function looks to wallet and if no wallet record can lookup ledger. + + :param wallet_handle: Wallet handle (created by open_wallet). + :param did: + :return: key: + """ + + logger = logging.getLogger(__name__) + logger.debug("key_for_local_did: >>> wallet_handle: %r, did: %r", + wallet_handle, + did) + + if not hasattr(key_for_local_did, "cb"): + logger.debug("key_for_local_did: Creating callback") + key_for_local_did.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p)) + + c_wallet_handle = c_int32(wallet_handle) + c_did = c_char_p(did.encode('utf-8')) + + key = await do_call('key_for_local_did', + c_wallet_handle, + c_did, + key_for_local_did.cb) + + res = key.decode() + + logger.debug("key_for_local_did: <<< res: %r", res) + return res + + async def set_endpoint_for_did(wallet_handle: int, did: str, address: str, diff --git a/wrappers/python/tests/signus/test_key_for_local_did.py b/wrappers/python/tests/signus/test_key_for_local_did.py new file mode 100644 index 0000000000..e2981e2739 --- /dev/null +++ b/wrappers/python/tests/signus/test_key_for_local_did.py @@ -0,0 +1,37 @@ +import json + +import pytest + +from indy import IndyError +from indy import signus +from indy.error import ErrorCode + + +@pytest.mark.asyncio +async def test_key_for_local_did_works_for_my_did(wallet_handle, identity_trustee1): + (did, verkey) = identity_trustee1 + received_key = await signus.key_for_local_did(wallet_handle, did) + assert verkey == received_key + + +@pytest.mark.asyncio +async def test_key_for_local_did_works_for_their_did(wallet_handle, did_my1, verkey_my1): + await signus.store_their_did(wallet_handle, json.dumps({'did': did_my1, 'verkey': verkey_my1})) + received_key = await signus.key_for_local_did(wallet_handle, did_my1) + assert verkey_my1 == received_key + + +@pytest.mark.asyncio +async def test_key_for_local_did_works_for_unknown_did(wallet_handle, did_my2): + with pytest.raises(IndyError) as e: + await signus.key_for_local_did(wallet_handle, did_my2) + assert ErrorCode.WalletNotFoundError == e.value.error_code + + +@pytest.mark.asyncio +async def test_key_for_local_did_works_for_invalid_wallet_handle(wallet_handle, identity_trustee1): + (did, _) = identity_trustee1 + with pytest.raises(IndyError) as e: + invalid_wallet_handle = wallet_handle + 1 + await signus.key_for_local_did(invalid_wallet_handle, did) + assert ErrorCode.WalletInvalidHandle == e.value.error_code From 5dce999d2a93dd86b8f8b356f6824212494d525b Mon Sep 17 00:00:00 2001 From: Vyacheslav Gudkov Date: Thu, 9 Nov 2017 17:46:45 +0300 Subject: [PATCH 02/14] * python wrapper tests were fixed Signed-off-by: Vyacheslav Gudkov --- wrappers/python/indy/signus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/python/indy/signus.py b/wrappers/python/indy/signus.py index e5db1cb269..d06e3582e5 100644 --- a/wrappers/python/indy/signus.py +++ b/wrappers/python/indy/signus.py @@ -655,7 +655,7 @@ async def key_for_local_did(wallet_handle: int, c_wallet_handle = c_int32(wallet_handle) c_did = c_char_p(did.encode('utf-8')) - key = await do_call('key_for_local_did', + key = await do_call('indy_key_for_local_did', c_wallet_handle, c_did, key_for_local_did.cb) From ae7a13b562533ea0b4176c0886d1345b3ad0cea9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Gudkov Date: Thu, 9 Nov 2017 18:48:18 +0300 Subject: [PATCH 03/14] * fixed documentation for indy_key_for_local_did call Signed-off-by: Vyacheslav Gudkov --- libindy/include/indy_signus.h | 12 +++++------- libindy/src/api/signus.rs | 15 +++++++-------- .../org/hyperledger/indy/sdk/signus/Signus.java | 16 +++++++--------- wrappers/python/indy/signus.py | 16 +++++++--------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/libindy/include/indy_signus.h b/libindy/include/indy_signus.h index 176655b52d..791127e505 100644 --- a/libindy/include/indy_signus.h +++ b/libindy/include/indy_signus.h @@ -126,17 +126,16 @@ extern "C" { /// Returns ver key (key id) for the given DID. /// - /// This call follow the idea that we resolve information about their DID from + /// "indy_key_for_did" call follow the idea that we resolve information about their DID from /// the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter /// that is used for checking the freshness of cached pool value. /// /// Note if you don't want to resolve their DID info from the ledger you can use - /// indy_key_for_local_did call instead that will look only to local wallet and skip + /// "indy_key_for_local_did" call instead that will look only to local wallet and skip /// freshness checking /// /// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. /// As result we can use returned ver key in all generic crypto and messaging functions. - /// Note that this function looks to wallet and if no wallet record can lookup ledger. /// /// #Params /// command_handle: Command handle to map callback to caller context. @@ -167,14 +166,13 @@ extern "C" { //// Returns ver key (key id) for the given DID. /// - /// This call looks data stored in the local wallet only and skips freshness checking. + /// "indy_key_for_local_did" call looks data stored in the local wallet only and skips freshness checking. /// - /// Note if you want to get fresh data from the ledger you can use indy_key_for_did call + /// Note if you want to get fresh data from the ledger you can use "indy_key_for_did" call /// instead. /// - /// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + /// Note that "indy_create_and_store_my_did" makes similar wallet record as "indy_create_key". /// As result we can use returned ver key in all generic crypto and messaging functions. - /// Note that this function looks to wallet and if no wallet record can lookup ledger. /// /// #Params /// command_handle: Command handle to map callback to caller context. diff --git a/libindy/src/api/signus.rs b/libindy/src/api/signus.rs index 1bad0f8151..de81e2e7db 100644 --- a/libindy/src/api/signus.rs +++ b/libindy/src/api/signus.rs @@ -188,17 +188,16 @@ pub extern fn indy_store_their_did(command_handle: i32, /// Returns ver key (key id) for the given DID. /// -/// This call follow the idea that we resolve information about their DID from +/// "indy_key_for_did" call follow the idea that we resolve information about their DID from /// the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter /// that is used for checking the freshness of cached pool value. /// /// Note if you don't want to resolve their DID info from the ledger you can use -/// indy_key_for_local_did call instead that will look only to local wallet and skip +/// "indy_key_for_local_did" call instead that will look only to the local wallet and skip /// freshness checking. /// -/// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. +/// Note that "indy_create_and_store_my_did" makes similar wallet record as "indy_create_key". /// As result we can use returned ver key in all generic crypto and messaging functions. -/// Note that this function looks to wallet and if no wallet record can lookup ledger. /// /// #Params /// command_handle: Command handle to map callback to caller context. @@ -245,14 +244,14 @@ pub extern fn indy_key_for_did(command_handle: i32, /// Returns ver key (key id) for the given DID. /// -/// This call looks data stored in the local wallet only and skips freshness checking. +/// "indy_key_for_local_did" call looks data stored in the local wallet only and skips freshness +/// checking. /// -/// Note if you want to get fresh data from the ledger you can use indy_key_for_did call +/// Note if you want to get fresh data from the ledger you can use "indy_key_for_did" call /// instead. /// -/// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. +/// Note that "indy_create_and_store_my_did" makes similar wallet record as "indy_create_key". /// As result we can use returned ver key in all generic crypto and messaging functions. -/// Note that this function looks to wallet and if no wallet record can lookup ledger. /// /// #Params /// command_handle: Command handle to map callback to caller context. diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java index 66c888e284..ca24105f84 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/signus/Signus.java @@ -678,17 +678,16 @@ public static CompletableFuture decryptSealed( /** * Returns ver key (key id) for the given DID. * - * This call follow the idea that we resolve information about their DID from - * the ledger with cache in the local wallet. The openWallet call has freshness parameter + * "keyForDid" call follow the idea that we resolve information about their DID from + * the ledger with cache in the local wallet. The "openWallet" call has freshness parameter * that is used for checking the freshness of cached pool value. * * Note if you don't want to resolve their DID info from the ledger you can use - * keyForLocalDid call instead that will look only to local wallet and skip + * "keyForLocalDid" call instead that will look only to local wallet and skip * freshness checking. * - * Note that createAndStoreMyDid makes similar wallet record as createKey. + * Note that "createAndStoreMyDid" makes similar wallet record as "createKey". * As result we can use returned ver key in all generic crypto and messaging functions. - * Note that this function looks to wallet and if no wallet record can lookup ledger. * * @param pool The pool. * @param wallet The wallet. @@ -726,14 +725,13 @@ public static CompletableFuture keyForDid( /** * Returns ver key (key id) for the given DID. * - * This call looks data stored in the local wallet only and skips freshness checking. + * "keyForLocalDid" call looks data stored in the local wallet only and skips freshness checking. * - * Note if you want to get fresh data from the ledger you can use indy_key_for_did call + * Note if you want to get fresh data from the ledger you can use "keyForDid" call * instead. * - * Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + * Note that "createAndStoreMyDid" makes similar wallet record as "createKey". * As result we can use returned ver key in all generic crypto and messaging functions. - * Note that this function looks to wallet and if no wallet record can lookup ledger. * * @param wallet The wallet. * @param did diff --git a/wrappers/python/indy/signus.py b/wrappers/python/indy/signus.py index d06e3582e5..df73a0baf7 100644 --- a/wrappers/python/indy/signus.py +++ b/wrappers/python/indy/signus.py @@ -580,17 +580,16 @@ async def key_for_did(pool_handle: int, """ Returns ver key (key id) for the given DID. - This call follow the idea that we resolve information about their DID from - the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter + "key_for_did" call follow the idea that we resolve information about their DID from + the ledger with cache in the local wallet. The "open_wallet" call has freshness parameter that is used for checking the freshness of cached pool value. Note if you don't want to resolve their DID info from the ledger you can use - indy_key_for_local_did call instead that will look only to local wallet and skip + "indy_key_for_local_did" call instead that will look only to local wallet and skip freshness checking. - Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + Note that "create_and_store_my_did" makes similar wallet record as "create_key". As result we can use returned ver key in all generic crypto and messaging functions. - Note that this function looks to wallet and if no wallet record can lookup ledger. :param pool_handle: Pool handle (created by open_pool). :param wallet_handle: Wallet handle (created by open_wallet). @@ -629,14 +628,13 @@ async def key_for_local_did(wallet_handle: int, """ Returns ver key (key id) for the given DID. - This call looks data stored in the local wallet only and skips freshness checking. + "key_for_local_did" call looks data stored in the local wallet only and skips freshness checking. - Note if you want to get fresh data from the ledger you can use indy_key_for_did call + Note if you want to get fresh data from the ledger you can use "key_for_did" call instead. - Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key. + Note that "create_and_store_my_did" makes similar wallet record as "create_key". As result we can use returned ver key in all generic crypto and messaging functions. - Note that this function looks to wallet and if no wallet record can lookup ledger. :param wallet_handle: Wallet handle (created by open_wallet). :param did: From 09c49a18c3a6ee6db4f6203fec1bdd2b089c7005 Mon Sep 17 00:00:00 2001 From: Symon Rottem Date: Fri, 10 Nov 2017 08:53:27 +1100 Subject: [PATCH 04/14] Implemented indy_key_for_local_did functionality and tests. Signed-off-by: Symon Rottem --- .../SignusTests/KeyForLocalDidTest.cs | 42 +++++++++++++++ .../SignusApi/NativeMethods.cs | 20 ++++++++ .../indy-sdk-dotnet/SignusApi/Signus.cs | 51 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs new file mode 100644 index 0000000000..6fc5ea3557 --- /dev/null +++ b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs @@ -0,0 +1,42 @@ +using Hyperledger.Indy.SignusApi; +using Hyperledger.Indy.WalletApi; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Threading.Tasks; + +namespace Hyperledger.Indy.Test.SignusTests +{ + [TestClass] + public class KeyForLocalDidTest : IndyIntegrationTestWithSingleWallet + { + [TestMethod] + public async Task TestKeyForLocalDidWorksForMyDid() + { + var result = await Signus.CreateAndStoreMyDidAsync(wallet, "{}"); + var did = result.Did; + var key = result.VerKey; + + var receivedKey = await Signus.KeyForLocalDidAsync(wallet, did); + + Assert.AreEqual(key, receivedKey); + } + + [TestMethod] + public async Task TestKeyForLocalDidWorksForTheirDid() + { + var identityJson = string.Format(IDENTITY_JSON_TEMPLATE, DID_FOR_MY1_SEED, VERKEY_FOR_MY1_SEED); + await Signus.StoreTheirDidAsync(wallet, identityJson); + + var receivedKey = await Signus.KeyForLocalDidAsync(wallet, DID_FOR_MY1_SEED); + + Assert.AreEqual(VERKEY_FOR_MY1_SEED, receivedKey); + } + + [TestMethod] + public async Task TestKeyForDidWorksForNoKey() + { + var ex = await Assert.ThrowsExceptionAsync(() => + Signus.KeyForLocalDidAsync(wallet, DID_FOR_MY2_SEED) + ); + } + } +} diff --git a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs index 5d740e1928..74b3ce1869 100644 --- a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs +++ b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs @@ -227,6 +227,25 @@ internal static class NativeMethods /// The verification key associated with the DID. internal delegate void SignusKeyForDidCompletedDelegate(int xcommand_handle, int err, string key); + /// + /// Returns ver key (key id) for the given DID. + /// + /// Command handle to map callback to caller context. + /// Wallet handle (created by open_wallet). + /// The DID to get the key for. + /// The function that will be called when the asynchronous call is complete. + /// 0 if the command was initiated successfully. Any non-zero result indicates an error. + [DllImport(Consts.NATIVE_LIB_NAME, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)] + internal static extern int indy_key_for_local_did(int command_handle, IntPtr wallet_handle, string did, SignusKeyForLocalDidCompletedDelegate cb); + + /// + /// Delegate to be used on completion of calls to indy_key_for_local_did. + /// + /// The handle for the command that initiated the callback. + /// The outcome of execution of the command. + /// The key associated with the DID. + internal delegate void SignusKeyForLocalDidCompletedDelegate(int xcommand_handle, int err, string key); + /// /// Sets the endpoint information for the given DID. /// @@ -291,5 +310,6 @@ internal static class NativeMethods /// The metadata associated with the DID. internal delegate void SignusGetDidMetadataCompletedDelegate(int xcommand_handle, int err, string metadata); + } } diff --git a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs index d67e5b7ea9..62ebb09156 100644 --- a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs +++ b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs @@ -153,6 +153,19 @@ public static class Signus taskCompletionSource.SetResult(key); }; + /// + /// Gets the callback to use when the command for KeyForLocalDidAsync has completed. + /// + private static SignusKeyForLocalDidCompletedDelegate _keyForLocalDidCompletedCallback = (xcommand_handle, err, key) => + { + var taskCompletionSource = PendingCommands.Remove(xcommand_handle); + + if (!CallbackHelper.CheckCallback(taskCompletionSource, err)) + return; + + taskCompletionSource.SetResult(key); + }; + /// /// Gets the callback to use when the command for GetEndpointForDidAsync has completed. /// @@ -181,6 +194,8 @@ public static class Signus taskCompletionSource.SetResult(metadata); }; + + /// /// Creates signing and encryption keys in specified wallet for a new DID owned by the caller. /// @@ -653,6 +668,42 @@ public static Task KeyForDidAsync(Pool pool, Wallet wallet, string did) return taskCompletionSource.Task; } + /// + /// Gets the verification key for the specified DID. + /// + /// + /// This method will obtain the verification key associated with the specified from the provided but will + /// not attempt to retrieve the key from the ledger if not present in the wallet, nor will it perform any freshness check against the ledger to determine + /// if the key is up-to-date. To ensure that the key is fresh use the method instead. + /// + /// The and methods both create + /// similar wallet records so the returned verification key in all generic crypto and messaging functions. + /// + /// + /// The wallet to resolve the DID from. + /// The DID to get the verification key for. + /// An asynchronous that resolves to a string containing the verification key associated with the DID. + /// Thrown if the DID could not be resolved from the . + public static Task KeyForLocalDidAsync(Wallet wallet, string did) + { + ParamGuard.NotNull(wallet, "wallet"); + ParamGuard.NotNullOrWhiteSpace(did, "did"); + + var taskCompletionSource = new TaskCompletionSource(); + var commandHandle = PendingCommands.Add(taskCompletionSource); + + var commandResult = NativeMethods.indy_key_for_local_did( + commandHandle, + wallet.Handle, + did, + _keyForLocalDidCompletedCallback + ); + + CallbackHelper.CheckResult(commandResult); + + return taskCompletionSource.Task; + } + /// /// Sets the endpoint details for the specified DID. /// From 59b9f03e80ee74142134e6b644755ea9f6bca30d Mon Sep 17 00:00:00 2001 From: Symon Rottem Date: Fri, 10 Nov 2017 10:38:35 +1100 Subject: [PATCH 05/14] Update indy_get_endpoint_for_did to support resolving from pool. Signed-off-by: Symon Rottem --- .../SignusTests/GetEndpointForDidTest.cs | 29 +++++++++++++++---- .../SignusTests/SetEndpointForDidTest.cs | 6 ++-- .../SignusApi/NativeMethods.cs | 3 +- .../indy-sdk-dotnet/SignusApi/Signus.cs | 11 +++++-- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/GetEndpointForDidTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/GetEndpointForDidTest.cs index 749e5efb3e..9d13a34c6c 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/GetEndpointForDidTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/GetEndpointForDidTest.cs @@ -1,27 +1,44 @@ -using Hyperledger.Indy.SignusApi; -using Hyperledger.Indy.WalletApi; +using Hyperledger.Indy.LedgerApi; +using Hyperledger.Indy.SignusApi; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Threading.Tasks; namespace Hyperledger.Indy.Test.SignusTests { [TestClass] - public class GetEndpointForDidTest : IndyIntegrationTestWithSingleWallet + public class GetEndpointForDidTest : IndyIntegrationTestWithPoolAndSingleWallet { [TestMethod] public async Task TestGetEndpointForDidWorks() { await Signus.SetEndpointForDidAsync(wallet, DID1, ENDPOINT, VERKEY); - var receivedEndpoint = await Signus.GetEndpointForDidAsync(wallet, DID1); + var receivedEndpoint = await Signus.GetEndpointForDidAsync(wallet, pool, DID1); Assert.AreEqual(ENDPOINT, receivedEndpoint.Address); Assert.AreEqual(VERKEY, receivedEndpoint.TransportKey); } + [TestMethod] + public async Task TestGetEndpointForDidWorksFromLedger() + { + var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); + var trusteeDid = trusteeDidResult.Did; + var trusteeVerKey = trusteeDidResult.VerKey; + + var endpoint = string.Format("{{\"endpoint\":{{\"ha\":\"{0}\",\"verkey\":\"{1}\"}}}}", ENDPOINT, trusteeVerKey); + + var attribRequest = await Ledger.BuildAttribRequestAsync(trusteeDid, trusteeDid, null, endpoint, null); + await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, attribRequest); + + var receivedEndpoint = await Signus.GetEndpointForDidAsync(wallet, pool, trusteeDid); + Assert.AreEqual(ENDPOINT, receivedEndpoint.Address); + Assert.AreEqual(trusteeVerKey, receivedEndpoint.TransportKey); + } + [TestMethod] public async Task TestGetEndpointForDidWorksForUnknownDid() { - var ex = await Assert.ThrowsExceptionAsync(() => - Signus.GetEndpointForDidAsync(wallet, DID1) + var ex = await Assert.ThrowsExceptionAsync(() => + Signus.GetEndpointForDidAsync(wallet, pool, DID1) ); } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs index 02ebf4a984..dd20eba561 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs @@ -5,7 +5,7 @@ namespace Hyperledger.Indy.Test.SignusTests { [TestClass] - public class SetEndpointForDidTest : IndyIntegrationTestWithSingleWallet + public class SetEndpointForDidTest : IndyIntegrationTestWithPoolAndSingleWallet { [TestMethod] public async Task TestSetEndpointForDidWorks() @@ -17,13 +17,13 @@ public async Task TestSetEndpointForDidWorks() public async Task TestSetEndpointForDidWorksForReplace() { await Signus.SetEndpointForDidAsync(wallet, DID1, ENDPOINT, VERKEY); - var receivedEndpoint = await Signus.GetEndpointForDidAsync(wallet, DID1); + var receivedEndpoint = await Signus.GetEndpointForDidAsync(wallet, pool, DID1); Assert.AreEqual(ENDPOINT, receivedEndpoint.Address); Assert.AreEqual(VERKEY, receivedEndpoint.TransportKey); var newEndpoint = "10.10.10.1:9710"; await Signus.SetEndpointForDidAsync(wallet, DID1, newEndpoint, VERKEY_FOR_MY2_SEED); - var updatedEndpoint = await Signus.GetEndpointForDidAsync(wallet, DID1); + var updatedEndpoint = await Signus.GetEndpointForDidAsync(wallet, pool, DID1); Assert.AreEqual(newEndpoint, updatedEndpoint.Address); Assert.AreEqual(VERKEY_FOR_MY2_SEED, updatedEndpoint.TransportKey); diff --git a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs index 74b3ce1869..0d2ae556fe 100644 --- a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs +++ b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/NativeMethods.cs @@ -264,11 +264,12 @@ internal static class NativeMethods /// /// Command handle to map callback to caller context. /// Wallet handle (created by open_wallet). + /// Pool handle (created by open_pool). /// The DID to set the endpoint on. /// The function that will be called when the asynchronous call is complete. /// 0 if the command was initiated successfully. Any non-zero result indicates an error. [DllImport(Consts.NATIVE_LIB_NAME, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)] - internal static extern int indy_get_endpoint_for_did(int command_handle, IntPtr wallet_handle, string did, SignusGetEndpointForDidCompletedDelegate cb); + internal static extern int indy_get_endpoint_for_did(int command_handle, IntPtr wallet_handle, IntPtr pool_handle, string did, SignusGetEndpointForDidCompletedDelegate cb); /// /// Delegate to be used on completion of calls to indy_get_endpoint_for_did. diff --git a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs index 62ebb09156..d5988df358 100644 --- a/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs +++ b/wrappers/dotnet/indy-sdk-dotnet/SignusApi/Signus.cs @@ -740,14 +740,20 @@ public static Task SetEndpointForDidAsync(Wallet wallet, string did, string addr /// /// Gets the endpoint details for the specified DID. /// + /// + /// If the is present in the and is considered "fresh" then + /// the endpoint will be resolved from the wallet. If, on the other hand, the DID is not present in the wallet or + /// is not fresh then the details will be resolved from the and will be cached in the wallet. + /// /// The wallet containing the DID. + /// The pool to resolve the endpoint data from if not present in the wallet. /// The DID to get the endpoint data for. /// An asynchronous that resolves to an containing the endpoint information /// associated with the DID. - /// Thrown if the does not exist in the . - public static Task GetEndpointForDidAsync(Wallet wallet, string did) + public static Task GetEndpointForDidAsync(Wallet wallet, Pool pool, string did) { ParamGuard.NotNull(wallet, "wallet"); + ParamGuard.NotNull(pool, "pool"); ParamGuard.NotNullOrWhiteSpace(did, "did"); var taskCompletionSource = new TaskCompletionSource(); @@ -756,6 +762,7 @@ public static Task GetEndpointForDidAsync(Wallet wallet, s var commandResult = NativeMethods.indy_get_endpoint_for_did( commandHandle, wallet.Handle, + pool.Handle, did, _getEndpointForDidCompletedCallback ); From 9e8788f15c838b62025432e4cb2c719abc2cb6d4 Mon Sep 17 00:00:00 2001 From: Symon Rottem Date: Fri, 10 Nov 2017 10:13:36 +1100 Subject: [PATCH 06/14] Refactor crypto tests. Signed-off-by: Symon Rottem --- .../AgentTests/AgentPrepAnonymousMsgTest.cs | 2 +- .../AgentTests/AgentPrepMsgTest.cs | 8 +++--- .../CryptoTests/BoxOpenTest.cs | 27 +++++++++---------- .../CryptoTests/BoxSealOpenTest.cs | 25 +++++++++-------- .../CryptoTests/BoxSealTest.cs | 16 ++++++----- .../CryptoTests/BoxTest.cs | 15 +++++------ .../CryptoTests/CryptoIntegrationTestBase.cs | 26 ------------------ .../CryptoTests/SignTest.cs | 9 ++++--- .../CryptoTests/VerifyTest.cs | 27 ++++++++++++------- .../DemoTests/SignusDemoTest.cs | 2 +- .../IndyIntegrationTestBase.cs | 25 +++++++++++------ .../SignusTests/CreateMyDidTest.cs | 14 +++++----- .../SignusTests/KeyForDidTest.cs | 16 +++++------ .../SignusTests/KeyForLocalDidTest.cs | 8 +++--- .../SignusTests/SetEndpointForDidTest.cs | 6 ++--- 15 files changed, 112 insertions(+), 114 deletions(-) delete mode 100644 wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/CryptoIntegrationTestBase.cs diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepAnonymousMsgTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepAnonymousMsgTest.cs index 996733fd97..c7207c22ad 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepAnonymousMsgTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepAnonymousMsgTest.cs @@ -37,7 +37,7 @@ private async Task CheckMessage(byte[] encryptedMsg) [TestMethod] public async Task TestPrepAnonymousMsgWorks() { - var encryptedMsg = await Agent.PrepAnonymousMsgAsync(VERKEY_FOR_MY1_SEED, MESSAGE); + var encryptedMsg = await Agent.PrepAnonymousMsgAsync(VERKEY_MY1, MESSAGE); await CheckMessage(encryptedMsg); } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepMsgTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepMsgTest.cs index 0f684741bf..3e08458d37 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepMsgTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/AgentTests/AgentPrepMsgTest.cs @@ -41,7 +41,7 @@ public async Task TestPrepMsgWorksForCreatedKey() var paramJson = string.Format("{{\"seed\":\"{0}\"}}", MY1_SEED); var senderVk = await Crypto.CreateKeyAsync(wallet, paramJson); - var encryptedMsg = await Agent.PrepMsgAsync(wallet, senderVk, VERKEY_FOR_MY2_SEED, MESSAGE); + var encryptedMsg = await Agent.PrepMsgAsync(wallet, senderVk, VERKEY_MY2, MESSAGE); await CheckMessage(senderVk, encryptedMsg); } @@ -54,7 +54,7 @@ public async Task TestPrepMsgWorksForCreatedDid() var result = await Signus.CreateAndStoreMyDidAsync(wallet, didJson); var senderVk = result.VerKey; - var encryptedMsg = await Agent.PrepMsgAsync(wallet, senderVk, VERKEY_FOR_MY2_SEED, MESSAGE); + var encryptedMsg = await Agent.PrepMsgAsync(wallet, senderVk, VERKEY_MY2, MESSAGE); await CheckMessage(senderVk, encryptedMsg); } @@ -68,7 +68,7 @@ public async Task TestPrepMsgWorksForCreatedDidAsCid() var result = await Signus.CreateAndStoreMyDidAsync(wallet, didJson); var senderVk = result.VerKey; - var encryptedMsg = await Agent.PrepMsgAsync(wallet, senderVk, VERKEY_FOR_MY2_SEED, MESSAGE); + var encryptedMsg = await Agent.PrepMsgAsync(wallet, senderVk, VERKEY_MY2, MESSAGE); await CheckMessage(senderVk, encryptedMsg); } @@ -77,7 +77,7 @@ public async Task TestPrepMsgWorksForCreatedDidAsCid() public async Task TestPrepMsgWorksForUnknownSenderVerkey() { var ex = await Assert.ThrowsExceptionAsync(() => - Agent.PrepMsgAsync(wallet, VERKEY, VERKEY_FOR_MY2_SEED, MESSAGE) + Agent.PrepMsgAsync(wallet, VERKEY, VERKEY_MY2, MESSAGE) ); } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxOpenTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxOpenTest.cs index 5afc791184..aee31a7fa9 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxOpenTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxOpenTest.cs @@ -1,51 +1,50 @@ using Hyperledger.Indy.CryptoApi; using Hyperledger.Indy.WalletApi; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; using System.Linq; using System.Threading.Tasks; namespace Hyperledger.Indy.Test.CryptoTests { [TestClass] - public class BoxOpenTest : CryptoIntegrationTestBase + public class BoxOpenTest : IndyIntegrationTestWithPoolAndSingleWallet { [TestMethod] public async Task TestBoxOpenWorks() { - var boxResult = await Crypto.BoxAsync(wallet, senderVerKey, recipientVerKey, MESSAGE); + var myVk = await Crypto.CreateKeyAsync(wallet, MY1_IDENTITY_KEY_JSON); - var decryptedMessage = await Crypto.BoxOpenAsync(wallet, recipientVerKey, senderVerKey, boxResult.EncryptedMessage, boxResult.Nonce); + var decryptedMessage = await Crypto.BoxOpenAsync(wallet, myVk, VERKEY_TRUSTEE, ENCRYPTED_MESSAGE, NONCE); Assert.IsTrue(MESSAGE.SequenceEqual(decryptedMessage)); } [TestMethod] - public async Task TestBoxOpenFailsIfRecipientKeyNotInWallet() + public async Task TestBoxOpenWorksForUnknownMyKey() { - var boxResult = await Crypto.BoxAsync(wallet, senderVerKey, recipientVerKey, MESSAGE); - var ex = await Assert.ThrowsExceptionAsync(() => - Crypto.BoxOpenAsync(wallet, KEY_NOT_IN_WALLET, senderVerKey, boxResult.EncryptedMessage, boxResult.Nonce) + Crypto.BoxOpenAsync(wallet, VERKEY_MY1, VERKEY_TRUSTEE, ENCRYPTED_MESSAGE, NONCE) ); } [TestMethod] - public async Task TestBoxOpenFailsIfSenderKeyNotInWallet() + public async Task TestBoxOpenWorksForOtherCoder() { - var boxResult = await Crypto.BoxAsync(wallet, senderVerKey, recipientVerKey, MESSAGE); + var myVk = await Crypto.CreateKeyAsync(wallet, MY1_IDENTITY_KEY_JSON); var ex = await Assert.ThrowsExceptionAsync(() => - Crypto.BoxOpenAsync(wallet, recipientVerKey, KEY_NOT_IN_WALLET, boxResult.EncryptedMessage, boxResult.Nonce) + Crypto.BoxOpenAsync(wallet, myVk, VERKEY_MY2, ENCRYPTED_MESSAGE, NONCE) ); } [TestMethod] - public async Task TestBoxOpenFailsIfNonceDoesNotMatchCiphertext() + public async Task TestBoxOpenWorksForNonceNotCorrespondMessage() { - var boxResult = await Crypto.BoxAsync(wallet, senderVerKey, recipientVerKey, MESSAGE); - var badNonce = new byte[] { 1, 2 }; + var nonce = (byte[])(Array)new sbyte[] { 46, 33, -4, 67, 1, 44, 57, -46, -91, 87, 14, 41, -39, 48, 42, -126, -121, 84, -58, 59, -27, 51, -32, -23}; + var myVk = await Crypto.CreateKeyAsync(wallet, MY1_IDENTITY_KEY_JSON); var ex = await Assert.ThrowsExceptionAsync(() => - Crypto.BoxOpenAsync(wallet, recipientVerKey, senderVerKey, boxResult.EncryptedMessage, badNonce) + Crypto.BoxOpenAsync(wallet, myVk, VERKEY_TRUSTEE, ENCRYPTED_MESSAGE, nonce) ); } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealOpenTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealOpenTest.cs index c517486117..041d6d3d31 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealOpenTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealOpenTest.cs @@ -7,34 +7,37 @@ namespace Hyperledger.Indy.Test.CryptoTests { [TestClass] - public class BoxSealOpenTest : CryptoIntegrationTestBase + public class BoxSealOpenTest : IndyIntegrationTestWithPoolAndSingleWallet { [TestMethod] public async Task TestBoxSealOpenWorks() { - var encryptedMessage = await Crypto.BoxSealAsync(recipientVerKey, MESSAGE); + var verkey = await Crypto.CreateKeyAsync(wallet, MY1_IDENTITY_KEY_JSON); + + var encryptedMessage = await Crypto.BoxSealAsync(verkey, MESSAGE); + var decryptedMessage = await Crypto.BoxSealOpenAsync(wallet, verkey, encryptedMessage); - var decryptedMessage = await Crypto.BoxSealOpenAsync(wallet, recipientVerKey, encryptedMessage); Assert.IsTrue(MESSAGE.SequenceEqual(decryptedMessage)); } [TestMethod] - public async Task TestBoxOpenFailsIfRecipientKeyNotInWallet() + public async Task TestBoxSealOpenWorksForOtherKey() { - var encryptedMessage = await Crypto.BoxSealAsync(recipientVerKey, MESSAGE); + var verkey = await Crypto.CreateKeyAsync(wallet, MY1_IDENTITY_KEY_JSON); + var encryptedMessage = await Crypto.BoxSealAsync(VERKEY_TRUSTEE, MESSAGE); - var ex = await Assert.ThrowsExceptionAsync(() => - Crypto.BoxSealOpenAsync(wallet, KEY_NOT_IN_WALLET, encryptedMessage) + var ex = await Assert.ThrowsExceptionAsync(() => + Crypto.BoxSealOpenAsync(wallet, verkey, encryptedMessage) ); } [TestMethod] - public async Task TestBoxOpenFailsIfKeyNotForEncryptedMessage() + public async Task TestBoxSealOpenWorksForUnknownKey() { - var encryptedMessage = await Crypto.BoxSealAsync(recipientVerKey, MESSAGE); + var encryptedMessage = await Crypto.BoxSealAsync(VERKEY_MY1, MESSAGE); - var ex = await Assert.ThrowsExceptionAsync(() => - Crypto.BoxSealOpenAsync(wallet, senderVerKey, encryptedMessage) + var ex = await Assert.ThrowsExceptionAsync(() => + Crypto.BoxSealOpenAsync(wallet, VERKEY_MY1, encryptedMessage) ); } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealTest.cs index 693afb3ec1..3cc5bc2738 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxSealTest.cs @@ -1,20 +1,24 @@ using Hyperledger.Indy.CryptoApi; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Linq; using System.Threading.Tasks; namespace Hyperledger.Indy.Test.CryptoTests { [TestClass] - public class BoxSealTest : CryptoIntegrationTestBase + public class BoxSealTest : IndyIntegrationTestBase { - [TestMethod] //Not sure if this is a good test, but since the encrypted content is not static... + [TestMethod] public async Task TestBoxSealWorks() { - var encryptedMessage = await Crypto.BoxSealAsync(recipientVerKey, MESSAGE); + await Crypto.BoxSealAsync(VERKEY_MY1, MESSAGE); + } - var decryptedMessage = await Crypto.BoxSealOpenAsync(wallet, recipientVerKey, encryptedMessage); - Assert.IsTrue(MESSAGE.SequenceEqual(decryptedMessage)); + [TestMethod] + public async Task TestBoxSealWorksForInvalidKey() + { + var ex = await Assert.ThrowsExceptionAsync(() => + Crypto.BoxSealAsync(INVALID_VERKEY, MESSAGE) + ); } } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxTest.cs index 87331552af..8bcf0ffd01 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/BoxTest.cs @@ -1,28 +1,25 @@ using Hyperledger.Indy.CryptoApi; using Hyperledger.Indy.WalletApi; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Linq; using System.Threading.Tasks; namespace Hyperledger.Indy.Test.CryptoTests { [TestClass] - public class BoxTest : CryptoIntegrationTestBase + public class BoxTest : IndyIntegrationTestWithSingleWallet { - [TestMethod] //Not sure if this is a good test, but since the encrypted content is not static... + [TestMethod] public async Task TestBoxWorks() { - var boxResult = await Crypto.BoxAsync(wallet, senderVerKey, recipientVerKey, MESSAGE); - - var decryptedMessage = await Crypto.BoxOpenAsync(wallet, recipientVerKey, senderVerKey, boxResult.EncryptedMessage, boxResult.Nonce); - Assert.IsTrue(MESSAGE.SequenceEqual(decryptedMessage)); + var myVk = await Crypto.CreateKeyAsync(wallet, MY1_IDENTITY_KEY_JSON); + await Crypto.BoxAsync(wallet, myVk, VERKEY_MY2, MESSAGE); } [TestMethod] - public async Task TestBoxFailsIfSenderKeyNotInWallet() + public async Task TestBoxWorksForUnknownCoder() { var ex = await Assert.ThrowsExceptionAsync(() => - Crypto.BoxAsync(wallet, KEY_NOT_IN_WALLET, recipientVerKey, MESSAGE) + Crypto.BoxAsync(wallet, VERKEY_MY1, VERKEY_MY2, MESSAGE) ); } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/CryptoIntegrationTestBase.cs b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/CryptoIntegrationTestBase.cs deleted file mode 100644 index 1e23c1a1ee..0000000000 --- a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/CryptoIntegrationTestBase.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Hyperledger.Indy.CryptoApi; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading.Tasks; - -namespace Hyperledger.Indy.Test.CryptoTests -{ - public abstract class CryptoIntegrationTestBase : IndyIntegrationTestWithSingleWallet - { - public readonly byte[] SIGNATURE = new byte[] { 169, 215, 8, 225, 7, 107, 110, 9, 193, 162, 202, 214, 162, 66, 238, 211, 63, 209, 12, 196, 8, 211, 55, 27, 120, 94, 204, 147, 53, 104, 103, 61, 60, 249, 237, 127, 103, 46, 220, 223, 10, 95, 75, 53, 245, 210, 241, 151, 191, 41, 48, 30, 9, 16, 78, 252, 157, 206, 210, 145, 125, 133, 109, 11 }; - public const string INVALID_BASE58_DID = "invalid_base58string"; - public const string KEY_NOT_IN_WALLET = "GjZWsBLgZCR18aL468JAT7w9CZRiBnpxUPPgyQxh4vob"; - - protected string senderVerKey; - protected string recipientVerKey; - - [TestInitialize] - public async Task CreateKeys() - { - var myKeyJson = string.Format("{{\"seed\":\"{0}\"}}", MY1_SEED); - senderVerKey = await Crypto.CreateKeyAsync(wallet, myKeyJson); - - var theirKeyJson = string.Format("{{\"seed\":\"{0}\"}}", MY2_SEED); - recipientVerKey = await Crypto.CreateKeyAsync(wallet, theirKeyJson); - } - } -} diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/SignTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/SignTest.cs index 44326718bc..c3499b3bc8 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/SignTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/SignTest.cs @@ -7,12 +7,15 @@ namespace Hyperledger.Indy.Test.CryptoTests { [TestClass] - public class SignTest : CryptoIntegrationTestBase + public class SignTest : IndyIntegrationTestWithSingleWallet { [TestMethod] public async Task TestSignWorks() { - var signature = await Crypto.SignAsync(wallet, senderVerKey, MESSAGE); + var keyJson = string.Format("{{\"seed\":\"{0}\"}}", TRUSTEE_SEED); + var key = await Crypto.CreateKeyAsync(wallet, keyJson); + + var signature = await Crypto.SignAsync(wallet, key, MESSAGE); Assert.IsTrue(SIGNATURE.SequenceEqual(signature)); } @@ -20,7 +23,7 @@ public async Task TestSignWorks() public async Task TestSignFailsIfKeyNotInWallet() { var ex = await Assert.ThrowsExceptionAsync(() => - Crypto.SignAsync(wallet, KEY_NOT_IN_WALLET, MESSAGE) + Crypto.SignAsync(wallet, VERKEY_TRUSTEE, MESSAGE) ); } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/VerifyTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/VerifyTest.cs index 90c2642617..3719e2e5dd 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/VerifyTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/CryptoTests/VerifyTest.cs @@ -1,34 +1,43 @@ using Hyperledger.Indy.CryptoApi; +using Hyperledger.Indy.SignusApi; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Threading.Tasks; namespace Hyperledger.Indy.Test.CryptoTests { [TestClass] - public class VerifyTest : CryptoIntegrationTestBase + public class VerifyTest : IndyIntegrationTestWithSingleWallet { [TestMethod] public async Task TestVerifyWorksWhenAllMatch() { - var result = await Crypto.VerifyAsync(senderVerKey, MESSAGE, SIGNATURE); + var result = await Crypto.VerifyAsync(VERKEY_TRUSTEE, MESSAGE, SIGNATURE); Assert.IsTrue(result); } [TestMethod] - public async Task TestVerifyWorksKeyDoesNotMatchSignature() + public async Task TestVerifyWorksForVerkeyWithCorrectCryptoType() { - var result = await Crypto.VerifyAsync(recipientVerKey, MESSAGE, SIGNATURE); - Assert.IsFalse(result); + var verkey = VERKEY_TRUSTEE + ":ed25519"; + var valid = await Crypto.VerifyAsync(verkey, MESSAGE, SIGNATURE); + Assert.IsTrue(valid); } [TestMethod] - public async Task TestVerifyWorksWhenSignatureDoesNotMatchMessage() + public async Task TestVerifyWorksForVerkeyWithInvalidCryptoType() { - var otherMessage = new byte[] { 1, 2 }; + var verkey = VERKEY_TRUSTEE + ":unknown_crypto"; - var result = await Crypto.VerifyAsync(senderVerKey, otherMessage, SIGNATURE); - Assert.IsFalse(result); + var ex = await Assert.ThrowsExceptionAsync(() => + Crypto.VerifyAsync(verkey, MESSAGE, SIGNATURE) + ); } + [TestMethod] + public async Task TestVerifyWorksForOtherSigner() + { + var valid = await Crypto.VerifyAsync(VERKEY_MY2, MESSAGE, SIGNATURE); + Assert.IsFalse(valid); + } } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/SignusDemoTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/SignusDemoTest.cs index e6e7fb066a..5dad37ced4 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/SignusDemoTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/SignusDemoTest.cs @@ -37,7 +37,7 @@ public async Task TestSignusDemo() var theirVerkey = createTheirDidResult.VerKey; // 6. Store Their DID - var identityJson = string.Format("{{\"did\":\"{0}\", \"verkey\":\"{1}\"}}", theirDid, theirVerkey); + var identityJson = string.Format(IDENTITY_JSON_TEMPLATE, theirDid, theirVerkey); await Signus.StoreTheirDidAsync(myWallet, identityJson); // 7. Their sign message diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/IndyIntegrationTestBase.cs b/wrappers/dotnet/indy-sdk-dotnet-test/IndyIntegrationTestBase.cs index 3feb747d9e..a6ab30335f 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/IndyIntegrationTestBase.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/IndyIntegrationTestBase.cs @@ -1,5 +1,6 @@ using Hyperledger.Indy.PoolApi; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; @@ -11,25 +12,33 @@ public abstract class IndyIntegrationTestBase protected const string TRUSTEE_SEED = "000000000000000000000000Trustee1"; protected const string MY1_SEED = "00000000000000000000000000000My1"; protected const string MY2_SEED = "00000000000000000000000000000My2"; + protected const string VERKEY = "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"; + protected const string VERKEY_MY1 = "GjZWsBLgZCR18aL468JAT7w9CZRiBnpxUPPgyQxh4voa"; + protected const string VERKEY_MY2 = "kqa2HyagzfMAq42H5f9u3UMwnSBPQx2QfrSyXbUPxMn"; + protected const string VERKEY_TRUSTEE = "GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL"; + protected const string INVALID_VERKEY = "CnEDk___MnmiHXEV1WFgbV___eYnPqs___TdcZaNhFVW"; protected const string DID1 = "8wZcEriaNLNKtteJvx7f8i"; + protected const string DID_MY1 = "VsKV7grR1BUE29mG2Fm2kX"; + protected const string DID_MY2 = "2PRyVHmkXQnQzJQKxHxnXC"; + protected const string DID_TRUSTEE = "V4SGRU86Z58d6TV7PBUe6f"; + protected const string INVALID_DID = "invalid_base58string"; protected const string IDENTITY_JSON_TEMPLATE = "{{\"did\":\"{0}\",\"verkey\":\"{1}\"}}"; protected readonly static byte[] MESSAGE = Encoding.UTF8.GetBytes("{\"reqId\":1496822211362017764}"); protected const string SCHEMA_DATA = "{\"name\":\"gvt2\",\"version\":\"3.0\",\"attr_names\": [\"name\", \"male\"]}"; protected const string POOL = "Pool1"; protected const string WALLET = "Wallet1"; protected const string TYPE = "default"; - protected readonly static string TRUSTEE_IDENTITY_JSON = string.Format("{{\"seed\":\"{0}\"}}", TRUSTEE_SEED); - protected const string VERKEY = "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"; - protected const string VERKEY_FOR_MY1_SEED = "GjZWsBLgZCR18aL468JAT7w9CZRiBnpxUPPgyQxh4voa"; - protected const string VERKEY_FOR_MY2_SEED = "kqa2HyagzfMAq42H5f9u3UMwnSBPQx2QfrSyXbUPxMn"; - protected const string DID_FOR_MY1_SEED = "VsKV7grR1BUE29mG2Fm2kX"; - protected const string DID_FOR_MY2_SEED = "2PRyVHmkXQnQzJQKxHxnXC"; protected const string METADATA = "some metadata"; protected const string ENDPOINT = "127.0.0.1:9700"; - protected const string INVALID_VERKEY = "CnEDk___MnmiHXEV1WFgbV___eYnPqs___TdcZaNhFVW"; protected const string CRYPTO_TYPE = "ed25519"; + protected readonly static byte[] SIGNATURE = (byte[])(Array)new sbyte[] { 20, -65, 100, -43, 101, 12, -59, -58, -53, 49, 89, -36, -51, -64, -32, -35, 97, 77, -36, -66, 90, 60, -114, 23, 16, -16, -67, -127, 45, -108, -11, 8, 102, 95, 95, -7, 100, 89, 41, -29, -43, 25, 100, 1, -24, -68, -11, -21, -70, 21, 52, -80, -20, 11, 99, 70, -101, -97, 89, -41, -59, -17, -118, 5 }; + protected readonly static byte[] ENCRYPTED_MESSAGE = (byte[])(Array)new sbyte[] { -105, 30, 89, 75, 76, 28, -59, -45, 105, -46, 20, 124, -85, -13, 109, 29, -88, -82, -8, -6, -50, -84, -53, -48, -49, 56, 124, 114, 82, 126, 74, 99, -72, -78, -117, 96, 60, 119, 50, -40, 121, 21, 57, -68, 89 }; + protected readonly static byte[] NONCE = (byte[])(Array)new sbyte[] { -14, 102, -41, -57, 1, 4, 75, -46, -91, 87, 14, 41, -39, 48, 42, -126, -121, 84, -58, 59, -27, 51, -32, -23 }; + - protected static string MY1_IDENTITY_JSON = string.Format("{{\"seed\":\"{0}\"}}", MY1_SEED); + protected readonly static string TRUSTEE_IDENTITY_JSON = string.Format("{{\"seed\":\"{0}\"}}", TRUSTEE_SEED); + protected readonly static string MY1_IDENTITY_JSON = string.Format("{{\"seed\":\"{0}\"}}", MY1_SEED); + protected readonly static string MY1_IDENTITY_KEY_JSON = string.Format("{{\"seed\":\"{0}\"}}", MY1_SEED); protected HashSet openedPools = new HashSet(); diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/CreateMyDidTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/CreateMyDidTest.cs index 48e87a60a1..dbcfc38009 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/CreateMyDidTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/CreateMyDidTest.cs @@ -24,8 +24,8 @@ public async Task TestCreateMyDidWorksForSeed() var result = await Signus.CreateAndStoreMyDidAsync(wallet, MY1_IDENTITY_JSON); Assert.IsNotNull(result); - Assert.AreEqual(DID_FOR_MY1_SEED, result.Did); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, result.VerKey); + Assert.AreEqual(DID_MY1, result.Did); + Assert.AreEqual(VERKEY_MY1, result.VerKey); } [TestMethod] @@ -36,8 +36,8 @@ public async Task TestCreateMyDidWorksAsCid() var result = await Signus.CreateAndStoreMyDidAsync(wallet, json); Assert.IsNotNull(result); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, result.Did); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, result.VerKey); + Assert.AreEqual(VERKEY_MY1, result.Did); + Assert.AreEqual(VERKEY_MY1, result.VerKey); } [TestMethod] @@ -59,8 +59,8 @@ public async Task TestCreateMyDidWorksForCorrectCryptoType() var result = await Signus.CreateAndStoreMyDidAsync(wallet, json); - Assert.AreEqual(DID_FOR_MY1_SEED, result.Did); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, result.VerKey); + Assert.AreEqual(DID_MY1, result.Did); + Assert.AreEqual(VERKEY_MY1, result.VerKey); } [TestMethod] @@ -92,7 +92,7 @@ public async Task TestCreateMyDidWorksForAllParams() Assert.IsNotNull(result); Assert.AreEqual(DID1, result.Did); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, result.VerKey); + Assert.AreEqual(VERKEY_MY1, result.VerKey); } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForDidTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForDidTest.cs index d8a5cae7e2..a57f53c524 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForDidTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForDidTest.cs @@ -24,12 +24,12 @@ public async Task TestKeyForDidWorksForMyDid() [TestMethod] public async Task TestKeyForDidWorksForTheirDid() { - var identityJson = string.Format("{{\"did\":\"{0}\", \"verkey\":\"{1}\"}}", DID_FOR_MY1_SEED, VERKEY_FOR_MY1_SEED); + var identityJson = string.Format(IDENTITY_JSON_TEMPLATE, DID_MY1, VERKEY_MY1); await Signus.StoreTheirDidAsync(wallet, identityJson); - var receivedKey = await Signus.KeyForDidAsync(pool, wallet, DID_FOR_MY1_SEED); + var receivedKey = await Signus.KeyForDidAsync(pool, wallet, DID_MY1); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, receivedKey); + Assert.AreEqual(VERKEY_MY1, receivedKey); } [TestMethod] @@ -38,22 +38,22 @@ public async Task TestKeyForDidWorksForGetKeyFromLedger() var result = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var trusteeDid = result.Did; - var identityJson = string.Format("{{\"did\":\"{0}\", \"verkey\":\"{1}\"}}", DID_FOR_MY1_SEED, VERKEY_FOR_MY1_SEED); + var identityJson = string.Format(IDENTITY_JSON_TEMPLATE, DID_MY1, VERKEY_MY1); await Signus.StoreTheirDidAsync(wallet, identityJson); - var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, DID_FOR_MY1_SEED, VERKEY_FOR_MY1_SEED, null, null); + var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, DID_MY1, VERKEY_MY1, null, null); await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest); - var receivedKey = await Signus.KeyForDidAsync(pool, wallet, DID_FOR_MY1_SEED); + var receivedKey = await Signus.KeyForDidAsync(pool, wallet, DID_MY1); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, receivedKey); + Assert.AreEqual(VERKEY_MY1, receivedKey); } [TestMethod] public async Task TestKeyForDidWorksForNoKey() { var ex = await Assert.ThrowsExceptionAsync(() => - Signus.KeyForDidAsync(pool, wallet, DID_FOR_MY2_SEED) + Signus.KeyForDidAsync(pool, wallet, DID_MY2) ); } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs index 6fc5ea3557..ec6ccda8e8 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/KeyForLocalDidTest.cs @@ -23,19 +23,19 @@ public async Task TestKeyForLocalDidWorksForMyDid() [TestMethod] public async Task TestKeyForLocalDidWorksForTheirDid() { - var identityJson = string.Format(IDENTITY_JSON_TEMPLATE, DID_FOR_MY1_SEED, VERKEY_FOR_MY1_SEED); + var identityJson = string.Format(IDENTITY_JSON_TEMPLATE, DID_MY1, VERKEY_MY1); await Signus.StoreTheirDidAsync(wallet, identityJson); - var receivedKey = await Signus.KeyForLocalDidAsync(wallet, DID_FOR_MY1_SEED); + var receivedKey = await Signus.KeyForLocalDidAsync(wallet, DID_MY1); - Assert.AreEqual(VERKEY_FOR_MY1_SEED, receivedKey); + Assert.AreEqual(VERKEY_MY1, receivedKey); } [TestMethod] public async Task TestKeyForDidWorksForNoKey() { var ex = await Assert.ThrowsExceptionAsync(() => - Signus.KeyForLocalDidAsync(wallet, DID_FOR_MY2_SEED) + Signus.KeyForLocalDidAsync(wallet, DID_MY2) ); } } diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs index dd20eba561..209abcefef 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/SignusTests/SetEndpointForDidTest.cs @@ -22,11 +22,11 @@ public async Task TestSetEndpointForDidWorksForReplace() Assert.AreEqual(VERKEY, receivedEndpoint.TransportKey); var newEndpoint = "10.10.10.1:9710"; - await Signus.SetEndpointForDidAsync(wallet, DID1, newEndpoint, VERKEY_FOR_MY2_SEED); + await Signus.SetEndpointForDidAsync(wallet, DID1, newEndpoint, VERKEY_MY2); var updatedEndpoint = await Signus.GetEndpointForDidAsync(wallet, pool, DID1); Assert.AreEqual(newEndpoint, updatedEndpoint.Address); - Assert.AreEqual(VERKEY_FOR_MY2_SEED, updatedEndpoint.TransportKey); + Assert.AreEqual(VERKEY_MY2, updatedEndpoint.TransportKey); } [TestMethod] @@ -45,4 +45,4 @@ public async Task TestSetEndpointForDidWorksForInvalidTransportKey() ); } } -} +} \ No newline at end of file From f3bad3b1297d4a485bba9ac6b16bf6ab564687a3 Mon Sep 17 00:00:00 2001 From: Symon Rottem Date: Fri, 10 Nov 2017 10:19:17 +1100 Subject: [PATCH 07/14] Update tests with schema referencing 'keys' to 'attr_names' to comply with updated SDK. Signed-off-by: Symon Rottem --- .../AnonCredsTests/AnonCredsIntegrationTestBase.cs | 2 +- .../IssuerCreateAndStoreClaimDefinitionTest.cs | 6 +++--- .../DemoTests/AnonCredsDemoTest.cs | 12 ++++++------ .../WalletTests/RegisterWalletTypeTest.cs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/AnonCredsIntegrationTestBase.cs b/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/AnonCredsIntegrationTestBase.cs index 0fa45c37e4..09e8228c4a 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/AnonCredsIntegrationTestBase.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/AnonCredsIntegrationTestBase.cs @@ -15,7 +15,7 @@ public abstract class AnonCredsIntegrationTestBase protected static string issuerDid2 = "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"; protected static string proverDid = "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"; protected static string claimOfferTemplate = "{{\"issuer_did\":\"{0}\",\"schema_seq_no\":{1}}}"; - protected static string schema = "{\"seqNo\":1,\"data\": {\"name\":\"gvt\",\"version\":\"1.0\",\"keys\":[\"age\",\"sex\",\"height\",\"name\"]}}"; + protected static string schema = "{\"seqNo\":1,\"data\": {\"name\":\"gvt\",\"version\":\"1.0\",\"attr_names\":[\"age\",\"sex\",\"height\",\"name\"]}}"; protected static string claimRequestTemplate = "{{\"blinded_ms\":" + "{{\"prover_did\":\"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW\"," + diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/IssuerCreateAndStoreClaimDefinitionTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/IssuerCreateAndStoreClaimDefinitionTest.cs index 4ac62653a9..adc7d4da78 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/IssuerCreateAndStoreClaimDefinitionTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/AnonCredsTests/IssuerCreateAndStoreClaimDefinitionTest.cs @@ -18,7 +18,7 @@ public class IssuerCreateAndStoreClaimDefinitionTest : AnonCredsIntegrationTestB " \"data\": {\n" + " \"name\":\"gvt\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[\"age\",\"sex\",\"height\",\"name\"]\n" + + " \"attr_names\":[\"age\",\"sex\",\"height\",\"name\"]\n" + " }\n" + " }"; @@ -58,7 +58,7 @@ public async Task TestIssuerCreateAndStoreClaimDefWorks() [TestMethod] public async Task TestIssuerCreateAndStoreClaimDefWorksForInvalidSchemaJson() { - var schema = "{\"seqNo\":1, \"name\":\"name\",\"version\":\"1.0\", \"keys\":[\"name\"]}"; + var schema = "{\"seqNo\":1, \"name\":\"name\",\"version\":\"1.0\", \"attr_names\":[\"name\"]}"; var ex = await Assert.ThrowsExceptionAsync(() => AnonCreds.IssuerCreateAndStoreClaimDefAsync(_wallet, _issuerDid, schema, null, false) @@ -73,7 +73,7 @@ public async Task TestIssuerCreateAndStoreClaimDefWorksForEmptyKeys() " \"data\": {\n" + " \"name\":\"gvt\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[]\n" + + " \"attr_names\":[]\n" + " }\n" + " }"; diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/AnonCredsDemoTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/AnonCredsDemoTest.cs index 39bdd5616f..e5ac81548d 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/AnonCredsDemoTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/DemoTests/AnonCredsDemoTest.cs @@ -60,7 +60,7 @@ public async Task TestAnonCredsDemo() " \"data\": {\n" + " \"name\":\"gvt\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[\"age\",\"sex\",\"height\",\"name\"]\n" + + " \"attr_names\":[\"age\",\"sex\",\"height\",\"name\"]\n" + " }\n" + " }"; var issuerDid = "NcYxiDXkpYi6ov5FcYDi1e"; @@ -180,7 +180,7 @@ public async Task TestAnonCredsWorksForMultipleIssuerSingleProver() " \"data\": {\n" + " \"name\":\"gvt\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[\"age\",\"sex\",\"height\",\"name\"]\n" + + " \"attr_names\":[\"age\",\"sex\",\"height\",\"name\"]\n" + " }\n" + " }"; @@ -192,7 +192,7 @@ public async Task TestAnonCredsWorksForMultipleIssuerSingleProver() " \"data\": {\n" + " \"name\":\"xyz\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[\"status\",\"period\"]\n" + + " \"attr_names\":[\"status\",\"period\"]\n" + " }\n" + " }"; @@ -333,7 +333,7 @@ public async Task TestAnonCredsWorksForSingleIssuerSingleProverMultipleClaims() " \"data\": {\n" + " \"name\":\"gvt\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[\"age\",\"sex\",\"height\",\"name\"]\n" + + " \"attr_names\":[\"age\",\"sex\",\"height\",\"name\"]\n" + " }\n" + " }"; @@ -345,7 +345,7 @@ public async Task TestAnonCredsWorksForSingleIssuerSingleProverMultipleClaims() " \"data\": {\n" + " \"name\":\"xyz\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[\"status\",\"period\"]\n" + + " \"attr_names\":[\"status\",\"period\"]\n" + " }\n" + " }"; @@ -472,7 +472,7 @@ public async Task TestVerifyProofWorksForProofDoesNotCorrespondToProofRequest() " \"data\": {\n" + " \"name\":\"gvt\",\n" + " \"version\":\"1.0\",\n" + - " \"keys\":[\"age\",\"sex\",\"height\",\"name\"]\n" + + " \"attr_names\":[\"age\",\"sex\",\"height\",\"name\"]\n" + " }\n" + " }"; var issuerDid = "NcYxiDXkpYi6ov5FcYDi1e"; diff --git a/wrappers/dotnet/indy-sdk-dotnet-test/WalletTests/RegisterWalletTypeTest.cs b/wrappers/dotnet/indy-sdk-dotnet-test/WalletTests/RegisterWalletTypeTest.cs index 9b09d1a3cc..232f423666 100644 --- a/wrappers/dotnet/indy-sdk-dotnet-test/WalletTests/RegisterWalletTypeTest.cs +++ b/wrappers/dotnet/indy-sdk-dotnet-test/WalletTests/RegisterWalletTypeTest.cs @@ -33,12 +33,12 @@ public async Task TestExerciseCustomWallet() var walletName = "exerciseWalletTypeWorks"; - await Wallet.CreateWalletAsync("default", walletName, "inmem", null, null); + await Wallet.CreateWalletAsync(POOL, walletName, _type, null, null); var wallet = await Wallet.OpenWalletAsync(walletName, null, null); Assert.IsNotNull(wallet); - var schema = "{\"seqNo\":1,\"data\": {\"name\":\"gvt\",\"version\":\"1.0\",\"keys\":[\"age\",\"sex\",\"height\",\"name\"]}}"; + var schema = "{\"seqNo\":1,\"data\": {\"name\":\"gvt\",\"version\":\"1.0\",\"attr_names\":[\"age\",\"sex\",\"height\",\"name\"]}}"; var claimDef = await AnonCreds.IssuerCreateAndStoreClaimDefAsync(wallet, DID1, schema, null, false); var claimOfferTemplate = "{{\"issuer_did\":\"{0}\",\"schema_seq_no\":{1}}}"; From f006753b961a801ac4be96a027cd516c6a9d881b Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Fri, 10 Nov 2017 14:42:39 +0300 Subject: [PATCH 08/14] Revert "Compatibility for indy-sdk master with state proofs against indy-node stable 1.1.43." This reverts commit c51e0093aed0e61afe3b106b044ff2c4b2bab66a. Signed-off-by: Sergey Minaev --- ci/indy-pool.dockerfile | 25 ++++++------ libindy/src/services/ledger/types.rs | 14 ------- libindy/tests/demo.rs | 1 - libindy/tests/ledger.rs | 38 +++++++++++-------- libindy/tests/utils/pool.rs | 8 ++-- .../indy/sdk/ledger/RequestsTest.java | 2 +- .../indy/sdk/ledger/SchemaRequestsTest.java | 5 ++- .../hyperledger/indy/sdk/utils/PoolUtils.java | 8 ++-- wrappers/python/tests/conftest.py | 8 ++-- .../tests/ledger/test_submit_request.py | 2 +- 10 files changed, 53 insertions(+), 58 deletions(-) diff --git a/ci/indy-pool.dockerfile b/ci/indy-pool.dockerfile index 5bb90daba6..20c037cd4f 100644 --- a/ci/indy-pool.dockerfile +++ b/ci/indy-pool.dockerfile @@ -19,19 +19,23 @@ RUN pip3 install -U \ setuptools RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 -ARG indy_stream=stable +ARG indy_stream=master RUN echo "deb https://repo.sovrin.org/deb xenial $indy_stream" >> /etc/apt/sources.list RUN useradd -ms /bin/bash -u $uid indy -ARG indy_plenum_ver=1.1.27 -ARG indy_anoncreds_ver=1.0.10 -ARG indy_node_ver=1.1.43 +ARG indy_plenum_ver=1.2.165 +ARG indy_anoncreds_ver=1.0.32 +ARG indy_node_ver=1.2.198 +ARG python3_indy_crypto_ver=0.1.6 +ARG indy_crypto_ver=0.1.6 RUN apt-get update -y && apt-get install -y \ indy-plenum=${indy_plenum_ver} \ indy-anoncreds=${indy_anoncreds_ver} \ indy-node=${indy_node_ver} \ + python3-indy-crypto=${python3_indy_crypto_ver} \ + libindy-crypto=${indy_crypto_ver} \ vim RUN echo '[supervisord]\n\ @@ -52,28 +56,28 @@ childlogdir = /tmp\n\ strip_ansi = false\n\ \n\ [program:node1]\n\ -command=start_sovrin_node Node1 9701 9702\n\ +command=start_indy_node Node1 9701 9702\n\ directory=/home/indy\n\ stdout_logfile=/tmp/node1.log\n\ stderr_logfile=/tmp/node1.log\n\ loglevel=trace\n\ \n\ [program:node2]\n\ -command=start_sovrin_node Node2 9703 9704\n\ +command=start_indy_node Node2 9703 9704\n\ directory=/home/indy\n\ stdout_logfile=/tmp/node2.log\n\ stderr_logfile=/tmp/node2.log\n\ loglevel=trace\n\ \n\ [program:node3]\n\ -command=start_sovrin_node Node3 9705 9706\n\ +command=start_indy_node Node3 9705 9706\n\ directory=/home/indy\n\ stdout_logfile=/tmp/node3.log\n\ stderr_logfile=/tmp/node3.log\n\ loglevel=trace\n\ \n\ [program:node4]\n\ -command=start_sovrin_node Node4 9707 9708\n\ +command=start_indy_node Node4 9707 9708\n\ directory=/home/indy\n\ stdout_logfile=/tmp/node4.log\n\ stderr_logfile=/tmp/node4.log\n\ @@ -84,10 +88,7 @@ USER indy ARG pool_ip=127.0.0.1 -RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 1 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip" -RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 2 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip" -RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 3 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip" -RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 4 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip" +RUN generate_indy_pool_transactions --nodes 4 --clients 5 --nodeNum 1 2 3 4 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip" EXPOSE 9701 9702 9703 9704 9705 9706 9707 9708 diff --git a/libindy/src/services/ledger/types.rs b/libindy/src/services/ledger/types.rs index 5ca1350846..3de15bf1d1 100644 --- a/libindy/src/services/ledger/types.rs +++ b/libindy/src/services/ledger/types.rs @@ -16,20 +16,6 @@ use services::ledger::constants::{ GET_TXN }; -#[cfg(not(test))] -#[derive(Serialize, PartialEq, Debug)] -#[serde(rename_all = "camelCase")] -pub struct Request { - pub req_id: u64, - pub identifier: String, - pub operation: T, - #[serde(skip_serializing)] - pub protocol_version: u64, - #[serde(skip_serializing_if = "Option::is_none")] - pub signature: Option -} - -#[cfg(test)] #[derive(Serialize, PartialEq, Debug)] #[serde(rename_all = "camelCase")] pub struct Request { diff --git a/libindy/tests/demo.rs b/libindy/tests/demo.rs index 16f71254d9..8146c262c7 100644 --- a/libindy/tests/demo.rs +++ b/libindy/tests/demo.rs @@ -562,7 +562,6 @@ fn ledger_demo_works() { req_id: u64, identifier: String, operation: Operation, - #[serde(skip_serializing)] protocol_version: u64, #[serde(skip_serializing_if = "Option::is_none")] signature: Option, diff --git a/libindy/tests/ledger.rs b/libindy/tests/ledger.rs index 27b4a6a904..291af80048 100644 --- a/libindy/tests/ledger.rs +++ b/libindy/tests/ledger.rs @@ -280,7 +280,8 @@ mod high_cases { \"operation\":{{\ \"dest\":\"{}\",\ \"type\":\"1\"\ - }}", IDENTIFIER, DEST); + }},\ + \"protocolVersion\":1", IDENTIFIER, DEST); let nym_request = LedgerUtils::build_nym_request(&IDENTIFIER, &DEST, None, None, None).unwrap(); assert!(nym_request.contains(&expected_result)); @@ -301,7 +302,8 @@ mod high_cases { \"role\":\"2\",\ \"type\":\"1\",\ \"verkey\":\"{}\"\ - }}", IDENTIFIER, alias, DEST, verkey); + }},\ + \"protocolVersion\":1", IDENTIFIER, alias, DEST, verkey); let nym_request = LedgerUtils::build_nym_request(&IDENTIFIER, &DEST, Some(verkey), Some(alias), Some(role)).unwrap(); assert!(nym_request.contains(&expected_result)); @@ -316,7 +318,8 @@ mod high_cases { \"dest\":\"{}\",\ \"role\":null,\ \"type\":\"1\"\ - }}", IDENTIFIER, DEST); + }},\ + \"protocolVersion\":1", IDENTIFIER, DEST); let nym_request = LedgerUtils::build_nym_request(&IDENTIFIER, &DEST, None, None, Some("")).unwrap(); assert!(nym_request.contains(&expected_result)); @@ -330,7 +333,8 @@ mod high_cases { \"operation\":{{\ \"type\":\"105\",\ \"dest\":\"{}\"\ - }}", IDENTIFIER, DEST); + }},\ + \"protocolVersion\":1", IDENTIFIER, DEST); let get_nym_request = LedgerUtils::build_get_nym_request(&IDENTIFIER, &DEST).unwrap(); assert!(get_nym_request.contains(&expected_result)); @@ -417,7 +421,8 @@ mod high_cases { \"type\":\"100\",\ \"dest\":\"{}\",\ \"raw\":\"{{\\\"endpoint\\\":{{\\\"ha\\\":\\\"127.0.0.1:5555\\\"}}}}\"\ - }}", IDENTIFIER, DEST); + }},\ + \"protocolVersion\":1", IDENTIFIER, DEST); let attrib_request = LedgerUtils::build_attrib_request(&IDENTIFIER, &DEST, None, Some(ATTRIB_RAW_DATA), None).unwrap(); assert!(attrib_request.contains(&expected_result)); @@ -441,7 +446,8 @@ mod high_cases { \"type\":\"104\",\ \"dest\":\"{}\",\ \"raw\":\"{}\"\ - }}", IDENTIFIER, DEST, raw); + }},\ + \"protocolVersion\":1", IDENTIFIER, DEST, raw); let get_attrib_request = LedgerUtils::build_get_attrib_request(&IDENTIFIER, &DEST, raw).unwrap(); assert!(get_attrib_request.contains(&expected_result)); @@ -504,7 +510,7 @@ mod high_cases { #[test] #[cfg(feature = "local_nodes_pool")] fn indy_build_schema_requests_works_for_correct_data_json() { - let expected_result = r#""operation":{"type":"101","data":{"name":"name","version":"1.0","attr_names":["name","male"]}}"#; + let expected_result = r#""operation":{"type":"101","data":{"name":"name","version":"1.0","attr_names":["name","male"]}},"protocolVersion":1"#; let schema_request = LedgerUtils::build_schema_request(IDENTIFIER, SCHEMA_DATA).unwrap(); assert!(schema_request.contains(expected_result)); @@ -513,7 +519,7 @@ mod high_cases { #[test] #[cfg(feature = "local_nodes_pool")] fn indy_build_get_schema_requests_works_for_correct_data_json() { - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"107","dest":"{}","data":{{"name":"name","version":"1.0"}}}}"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"107","dest":"{}","data":{{"name":"name","version":"1.0"}}}},"protocolVersion":1"#, IDENTIFIER, DEST); let get_schema_request = LedgerUtils::build_get_schema_request(IDENTIFIER, DEST, GET_SCHEMA_DATA).unwrap(); @@ -572,7 +578,7 @@ mod high_cases { #[test] fn indy_build_node_request_works_for_correct_data_json() { - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"0","dest":"{}","data":{{"node_ip":"10.0.0.100","node_port":1,"client_ip":"10.0.0.100","client_port":1,"alias":"some","services":["VALIDATOR"],"blskey":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"}}}}"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"0","dest":"{}","data":{{"node_ip":"10.0.0.100","node_port":1,"client_ip":"10.0.0.100","client_port":1,"alias":"some","services":["VALIDATOR"],"blskey":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"}}}},"protocolVersion":1"#, IDENTIFIER, DEST); let node_request = LedgerUtils::build_node_request(IDENTIFIER, DEST, NODE_DATA).unwrap(); @@ -635,7 +641,7 @@ mod high_cases { fn indy_build_claim_def_request_works_for_correct_data_json() { let data = r#"{"primary":{"n":"1","s":"2","rms":"3","r":{"name":"1"},"rctxt":"1","z":"1"}}"#; - let expected_result = format!(r#""identifier":"{}","operation":{{"ref":{},"data":{{"primary":{{"n":"1","s":"2","rms":"3","r":{{"name":"1"}},"rctxt":"1","z":"1"}},"revocation":{{}}}},"type":"102","signature_type":"{}"}}"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"ref":{},"data":{{"primary":{{"n":"1","s":"2","rms":"3","r":{{"name":"1"}},"rctxt":"1","z":"1"}},"revocation":{{}}}},"type":"102","signature_type":"{}"}},"protocolVersion":1"#, IDENTIFIER, SEQ_NO, SIGNATURE_TYPE); let claim_def_request = LedgerUtils::build_claim_def_txn(IDENTIFIER, SEQ_NO, SIGNATURE_TYPE, &data).unwrap(); @@ -646,7 +652,7 @@ mod high_cases { fn indy_build_get_claim_def_request_works() { let origin = "origin"; - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"108","ref":{},"signature_type":"{}","origin":"{}"}}"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"108","ref":{},"signature_type":"{}","origin":"{}"}},"protocolVersion":1"#, IDENTIFIER, SEQ_NO, SIGNATURE_TYPE, origin); let get_claim_def_request = LedgerUtils::build_get_claim_def_txn(IDENTIFIER, SEQ_NO, SIGNATURE_TYPE, origin).unwrap(); @@ -729,7 +735,7 @@ mod high_cases { #[test] fn indy_build_get_txn_request() { - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"3","data":{}}}"#, IDENTIFIER, SEQ_NO); + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"3","data":{}}},"protocolVersion":1"#, IDENTIFIER, SEQ_NO); let get_txn_request = LedgerUtils::build_get_txn_request(IDENTIFIER, SEQ_NO).unwrap(); assert!(get_txn_request.contains(&expected_result)); @@ -1072,7 +1078,7 @@ mod medium_cases { let get_nym_response_without_role: Reply = serde_json::from_str(&get_nym_response_without_role).unwrap(); let get_nym_response_data_without_role: GetNymResultData = serde_json::from_str(&get_nym_response_without_role.result.data.unwrap()).unwrap(); - assert_eq!(get_nym_response_data_without_role.role.clone().unwrap_or("".to_string()), "".to_string()); + assert!(get_nym_response_data_without_role.role.is_none()); assert_ne!(get_nym_response_data_without_role.role, get_nym_response_data_with_role.role); PoolUtils::close(pool_handle).unwrap(); @@ -1265,8 +1271,10 @@ mod medium_cases { let get_schema_request = LedgerUtils::build_get_schema_request(&did, &did, get_schema_data).unwrap(); let get_schema_response = PoolUtils::send_request(pool_handle, &get_schema_request).unwrap(); - let get_schema_response: Reply = serde_json::from_str(&get_schema_response).unwrap(); - assert!(get_schema_response.result.data.is_none()); + // TODO FIXME restore after INDY-699 will be fixed + // let get_schema_response: Reply = serde_json::from_str(&get_schema_response).unwrap(); + // assert!(get_schema_response.result.data.is_none()); + assert!(serde_json::from_str::>(&get_schema_response).unwrap_err().to_string().contains("missing field `attr_names`")); PoolUtils::close(pool_handle).unwrap(); WalletUtils::close_wallet(wallet_handle).unwrap(); diff --git a/libindy/tests/utils/pool.rs b/libindy/tests/utils/pool.rs index 23cc1a7cea..7164df0726 100644 --- a/libindy/tests/utils/pool.rs +++ b/libindy/tests/utils/pool.rs @@ -59,10 +59,10 @@ impl PoolUtils { let test_pool_ip = EnvironmentUtils::test_pool_ip(); let node_txns = vec![ - format!("{{\"data\":{{\"alias\":\"Node1\",\"client_ip\":\"{}\",\"client_port\":9702,\"node_ip\":\"{}\",\"node_port\":9701,\"services\":[\"VALIDATOR\"]}},\"dest\":\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\",\"identifier\":\"Th7MpTaRZVRYnPiabds81Y\",\"txnId\":\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip), - format!("{{\"data\":{{\"alias\":\"Node2\",\"client_ip\":\"{}\",\"client_port\":9704,\"node_ip\":\"{}\",\"node_port\":9703,\"services\":[\"VALIDATOR\"]}},\"dest\":\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\",\"identifier\":\"EbP4aYNeTHL6q385GuVpRV\",\"txnId\":\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip), - format!("{{\"data\":{{\"alias\":\"Node3\",\"client_ip\":\"{}\",\"client_port\":9706,\"node_ip\":\"{}\",\"node_port\":9705,\"services\":[\"VALIDATOR\"]}},\"dest\":\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\",\"identifier\":\"4cU41vWW82ArfxJxHkzXPG\",\"txnId\":\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip), - format!("{{\"data\":{{\"alias\":\"Node4\",\"client_ip\":\"{}\",\"client_port\":9708,\"node_ip\":\"{}\",\"node_port\":9707,\"services\":[\"VALIDATOR\"]}},\"dest\":\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\",\"identifier\":\"TWwCRQRZ2ZHMJFn9TzLp7W\",\"txnId\":\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip)]; + format!("{{\"data\":{{\"alias\":\"Node1\",\"blskey\":\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\",\"client_ip\":\"{}\",\"client_port\":9702,\"node_ip\":\"{}\",\"node_port\":9701,\"services\":[\"VALIDATOR\"]}},\"dest\":\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\",\"identifier\":\"Th7MpTaRZVRYnPiabds81Y\",\"txnId\":\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip), + format!("{{\"data\":{{\"alias\":\"Node2\",\"blskey\":\"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk\",\"client_ip\":\"{}\",\"client_port\":9704,\"node_ip\":\"{}\",\"node_port\":9703,\"services\":[\"VALIDATOR\"]}},\"dest\":\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\",\"identifier\":\"EbP4aYNeTHL6q385GuVpRV\",\"txnId\":\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip), + format!("{{\"data\":{{\"alias\":\"Node3\",\"blskey\":\"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5\",\"client_ip\":\"{}\",\"client_port\":9706,\"node_ip\":\"{}\",\"node_port\":9705,\"services\":[\"VALIDATOR\"]}},\"dest\":\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\",\"identifier\":\"4cU41vWW82ArfxJxHkzXPG\",\"txnId\":\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip), + format!("{{\"data\":{{\"alias\":\"Node4\",\"blskey\":\"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw\",\"client_ip\":\"{}\",\"client_port\":9708,\"node_ip\":\"{}\",\"node_port\":9707,\"services\":[\"VALIDATOR\"]}},\"dest\":\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\",\"identifier\":\"TWwCRQRZ2ZHMJFn9TzLp7W\",\"txnId\":\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\",\"type\":\"0\"}}", test_pool_ip, test_pool_ip)]; let txn_file_data = node_txns[0..(nodes_count as usize)].join("\n"); diff --git a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/RequestsTest.java b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/RequestsTest.java index f676fdc693..a579662b71 100644 --- a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/RequestsTest.java +++ b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/RequestsTest.java @@ -33,7 +33,7 @@ public void testSubmitRequestWorks() throws Exception { Assert.assertEquals("REPLY", responseObject.getString("op")); Assert.assertEquals("105", responseObject.getJSONObject("result").getString("type")); Assert.assertEquals(1491566332010860L, responseObject.getJSONObject("result").getLong("reqId")); - Assert.assertEquals("{\"dest\":\"Th7MpTaRZVRYnPiabds81Y\",\"identifier\":\"V4SGRU86Z58d6TV7PBUe6f\",\"role\":\"2\",\"verkey\":\"~7TYfekw4GUagBnBVCqPjiC\"}", responseObject.getJSONObject("result").getString("data")); + Assert.assertEquals("{\"dest\":\"Th7MpTaRZVRYnPiabds81Y\",\"identifier\":\"V4SGRU86Z58d6TV7PBUe6f\",\"role\":\"2\",\"seqNo\":2,\"txnTime\":null,\"verkey\":\"~7TYfekw4GUagBnBVCqPjiC\"}", responseObject.getJSONObject("result").getString("data")); Assert.assertEquals("Th7MpTaRZVRYnPiabds81Y", responseObject.getJSONObject("result").getString("identifier")); Assert.assertEquals("Th7MpTaRZVRYnPiabds81Y", responseObject.getJSONObject("result").getString("dest")); } diff --git a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/SchemaRequestsTest.java b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/SchemaRequestsTest.java index 8780529cc3..bb319d5595 100644 --- a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/SchemaRequestsTest.java +++ b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/ledger/SchemaRequestsTest.java @@ -12,7 +12,6 @@ import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; public class SchemaRequestsTest extends IndyIntegrationTestWithPoolAndSingleWallet { @@ -92,7 +91,9 @@ public void testGetSchemaRequestsWorksForUnknownSchema() throws Exception { JSONObject getSchemaResponseObject = new JSONObject(getSchemaResponse); - assertNull(getSchemaResponseObject.getJSONObject("result").optJSONObject("data")); + // TODO FIXME restore after INDY-699 will be fixed + // assertNull(getSchemaResponseObject.getJSONObject("result").optJSONObject("data")); + assertEquals(getSchemaResponseObject.getJSONObject("result").optJSONObject("data").toString(), getSchemaData); } @Test diff --git a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/utils/PoolUtils.java b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/utils/PoolUtils.java index e338d1a920..968a5d8feb 100644 --- a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/utils/PoolUtils.java +++ b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/utils/PoolUtils.java @@ -34,10 +34,10 @@ public static void writeTransactions(File file, int nodesCnt) throws IOException String testPoolIp = EnvironmentUtils.getTestPoolIP(); String[] defaultTxns = new String[]{ - String.format("{\"data\":{\"alias\":\"Node1\",\"client_ip\":\"%s\",\"client_port\":9702,\"node_ip\":\"%s\",\"node_port\":9701,\"services\":[\"VALIDATOR\"]},\"dest\":\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\",\"identifier\":\"Th7MpTaRZVRYnPiabds81Y\",\"txnId\":\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\",\"type\":\"0\"}", testPoolIp, testPoolIp), - String.format("{\"data\":{\"alias\":\"Node2\",\"client_ip\":\"%s\",\"client_port\":9704,\"node_ip\":\"%s\",\"node_port\":9703,\"services\":[\"VALIDATOR\"]},\"dest\":\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\",\"identifier\":\"EbP4aYNeTHL6q385GuVpRV\",\"txnId\":\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\",\"type\":\"0\"}", testPoolIp, testPoolIp), - String.format("{\"data\":{\"alias\":\"Node3\",\"client_ip\":\"%s\",\"client_port\":9706,\"node_ip\":\"%s\",\"node_port\":9705,\"services\":[\"VALIDATOR\"]},\"dest\":\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\",\"identifier\":\"4cU41vWW82ArfxJxHkzXPG\",\"txnId\":\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\",\"type\":\"0\"}", testPoolIp, testPoolIp), - String.format("{\"data\":{\"alias\":\"Node4\",\"client_ip\":\"%s\",\"client_port\":9708,\"node_ip\":\"%s\",\"node_port\":9707,\"services\":[\"VALIDATOR\"]},\"dest\":\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\",\"identifier\":\"TWwCRQRZ2ZHMJFn9TzLp7W\",\"txnId\":\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\",\"type\":\"0\"}", testPoolIp, testPoolIp) + String.format("{\"data\":{\"alias\":\"Node1\",\"blskey\":\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\",\"client_ip\":\"%s\",\"client_port\":9702,\"node_ip\":\"%s\",\"node_port\":9701,\"services\":[\"VALIDATOR\"]},\"dest\":\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\",\"identifier\":\"Th7MpTaRZVRYnPiabds81Y\",\"txnId\":\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\",\"type\":\"0\"}", testPoolIp, testPoolIp), + String.format("{\"data\":{\"alias\":\"Node2\",\"blskey\":\"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk\",\"client_ip\":\"%s\",\"client_port\":9704,\"node_ip\":\"%s\",\"node_port\":9703,\"services\":[\"VALIDATOR\"]},\"dest\":\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\",\"identifier\":\"EbP4aYNeTHL6q385GuVpRV\",\"txnId\":\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\",\"type\":\"0\"}", testPoolIp, testPoolIp), + String.format("{\"data\":{\"alias\":\"Node3\",\"blskey\":\"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5\",\"client_ip\":\"%s\",\"client_port\":9706,\"node_ip\":\"%s\",\"node_port\":9705,\"services\":[\"VALIDATOR\"]},\"dest\":\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\",\"identifier\":\"4cU41vWW82ArfxJxHkzXPG\",\"txnId\":\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\",\"type\":\"0\"}", testPoolIp, testPoolIp), + String.format("{\"data\":{\"alias\":\"Node4\",\"blskey\":\"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw\",\"client_ip\":\"%s\",\"client_port\":9708,\"node_ip\":\"%s\",\"node_port\":9707,\"services\":[\"VALIDATOR\"]},\"dest\":\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\",\"identifier\":\"TWwCRQRZ2ZHMJFn9TzLp7W\",\"txnId\":\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\",\"type\":\"0\"}", testPoolIp, testPoolIp) }; FileWriter fw = new FileWriter(file); diff --git a/wrappers/python/tests/conftest.py b/wrappers/python/tests/conftest.py index 29dd6592e7..d68ba8e862 100644 --- a/wrappers/python/tests/conftest.py +++ b/wrappers/python/tests/conftest.py @@ -280,13 +280,13 @@ def pool_genesis_txn_data(pool_genesis_txn_count, pool_ip): assert 0 < pool_genesis_txn_count <= 4 res = "\n".join([ - '{{"data":{{"alias":"Node1","client_ip":"{}","client_port":9702,"node_ip":"{}","node_port":9701,"services":["VALIDATOR"]}},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv","identifier":"Th7MpTaRZVRYnPiabds81Y","txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62","type":"0"}}'.format( + '{{"data":{{"alias":"Node1","blskey":"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba","client_ip":"{}","client_port":9702,"node_ip":"{}","node_port":9701,"services":["VALIDATOR"]}},"dest":"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv","identifier":"Th7MpTaRZVRYnPiabds81Y","txnId":"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62","type":"0"}}'.format( pool_ip, pool_ip), - '{{"data":{{"alias":"Node2","client_ip":"{}","client_port":9704,"node_ip":"{}","node_port":9703,"services":["VALIDATOR"]}},"dest":"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb","identifier":"EbP4aYNeTHL6q385GuVpRV","txnId":"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc","type":"0"}}'.format( + '{{"data":{{"alias":"Node2","blskey":"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk","client_ip":"{}","client_port":9704,"node_ip":"{}","node_port":9703,"services":["VALIDATOR"]}},"dest":"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb","identifier":"EbP4aYNeTHL6q385GuVpRV","txnId":"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc","type":"0"}}'.format( pool_ip, pool_ip), - '{{"data":{{"alias":"Node3","client_ip":"{}","client_port":9706,"node_ip":"{}","node_port":9705,"services":["VALIDATOR"]}},"dest":"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya","identifier":"4cU41vWW82ArfxJxHkzXPG","txnId":"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4","type":"0"}}'.format( + '{{"data":{{"alias":"Node3","blskey":"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5","client_ip":"{}","client_port":9706,"node_ip":"{}","node_port":9705,"services":["VALIDATOR"]}},"dest":"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya","identifier":"4cU41vWW82ArfxJxHkzXPG","txnId":"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4","type":"0"}}'.format( pool_ip, pool_ip), - '{{"data":{{"alias":"Node4","client_ip":"{}","client_port":9708,"node_ip":"{}","node_port":9707,"services":["VALIDATOR"]}},"dest":"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA","identifier":"TWwCRQRZ2ZHMJFn9TzLp7W","txnId":"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008","type":"0"}}'.format( + '{{"data":{{"alias":"Node4","blskey":"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw","client_ip":"{}","client_port":9708,"node_ip":"{}","node_port":9707,"services":["VALIDATOR"]}},"dest":"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA","identifier":"TWwCRQRZ2ZHMJFn9TzLp7W","txnId":"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008","type":"0"}}'.format( pool_ip, pool_ip) ][0:pool_genesis_txn_count]) diff --git a/wrappers/python/tests/ledger/test_submit_request.py b/wrappers/python/tests/ledger/test_submit_request.py index 2c78cbbcb5..5ad3da527f 100644 --- a/wrappers/python/tests/ledger/test_submit_request.py +++ b/wrappers/python/tests/ledger/test_submit_request.py @@ -24,7 +24,7 @@ async def test_submit_request_works(pool_handle): "identifier": "Th7MpTaRZVRYnPiabds81Y", "dest": "Th7MpTaRZVRYnPiabds81Y", "data": "{\"dest\":\"Th7MpTaRZVRYnPiabds81Y\",\"identifier\":\"V4SGRU86Z58d6TV7PBUe6f\",\"role\":\"2\"" - ",\"verkey\":\"~7TYfekw4GUagBnBVCqPjiC\"}", + ",\"seqNo\":2,\"txnTime\":null,\"verkey\":\"~7TYfekw4GUagBnBVCqPjiC\"}", "type": "105", }, "op": "REPLY" From 5e62be1d9fab1f486fd30fcf830e165dfea4200b Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Tue, 9 Jan 2018 16:17:55 +0300 Subject: [PATCH 09/14] Change node version to 1.2.50. Signed-off-by: Sergey Minaev --- ci/indy-pool.dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/indy-pool.dockerfile b/ci/indy-pool.dockerfile index 20c037cd4f..0b78a7e721 100644 --- a/ci/indy-pool.dockerfile +++ b/ci/indy-pool.dockerfile @@ -19,14 +19,14 @@ RUN pip3 install -U \ setuptools RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 -ARG indy_stream=master +ARG indy_stream=stable RUN echo "deb https://repo.sovrin.org/deb xenial $indy_stream" >> /etc/apt/sources.list RUN useradd -ms /bin/bash -u $uid indy -ARG indy_plenum_ver=1.2.165 -ARG indy_anoncreds_ver=1.0.32 -ARG indy_node_ver=1.2.198 +ARG indy_plenum_ver=1.2.29 +ARG indy_anoncreds_ver=1.0.11 +ARG indy_node_ver=1.2.50 ARG python3_indy_crypto_ver=0.1.6 ARG indy_crypto_ver=0.1.6 From 6dca149adb9858312735b6337b0428fff12bb792 Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Tue, 9 Jan 2018 16:31:28 +0300 Subject: [PATCH 10/14] Increment versions to 1.2.0. Signed-off-by: Sergey Minaev --- libindy/Cargo.lock | 2 +- libindy/Cargo.toml | 2 +- libindy/debian/changelog | 6 ++---- wrappers/java/pom.xml | 2 +- wrappers/python/setup.py | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libindy/Cargo.lock b/libindy/Cargo.lock index bf5b6813da..546232301c 100644 --- a/libindy/Cargo.lock +++ b/libindy/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "indy" -version = "1.1.1" +version = "1.2.0" dependencies = [ "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/libindy/Cargo.toml b/libindy/Cargo.toml index fa93d46222..882b3cb544 100644 --- a/libindy/Cargo.toml +++ b/libindy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indy" -version = "1.1.1" +version = "1.2.0" authors = [ "Sergej Pupykin ", "Vyacheslav Gudkov ", diff --git a/libindy/debian/changelog b/libindy/debian/changelog index 0dc0188815..712ffb9378 100644 --- a/libindy/debian/changelog +++ b/libindy/debian/changelog @@ -1,6 +1,4 @@ -libindy (1.1.1) unstable; urgency=medium +libindy (1.2.0) unstable; urgency=medium [ Hyperledger ] - * Replaced Agent2Agent API - * New Crypto API - * Updated Signus API + * indy_key_for_local_did added diff --git a/wrappers/java/pom.xml b/wrappers/java/pom.xml index ff6705281b..fc0121355f 100644 --- a/wrappers/java/pom.xml +++ b/wrappers/java/pom.xml @@ -5,7 +5,7 @@ org.hyperledger indy jar - 1.1.1 + 1.2.0 indy This is the official SDK for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org). diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index e718543394..d5771ff89c 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -2,7 +2,7 @@ setup( name='python3-indy', - version='1.1.1', + version='1.2.0', packages=['indy'], url='https://github.com/hyperledger/indy-sdk', license='MIT/Apache-2.0', From 6f257af4dfec8662ddef1271e6bc10a2a988104f Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Tue, 9 Jan 2018 16:44:36 +0300 Subject: [PATCH 11/14] Add iOS podspecs for 1.2.0 build. Signed-off-by: Sergey Minaev --- .../1.2.0/libindy-objc.podspec.json | 23 +++++++++++++++++++ Specs/libindy/1.2.0/libindy.podspec.json | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Specs/libindy-objc/1.2.0/libindy-objc.podspec.json create mode 100644 Specs/libindy/1.2.0/libindy.podspec.json diff --git a/Specs/libindy-objc/1.2.0/libindy-objc.podspec.json b/Specs/libindy-objc/1.2.0/libindy-objc.podspec.json new file mode 100644 index 0000000000..bbc519732c --- /dev/null +++ b/Specs/libindy-objc/1.2.0/libindy-objc.podspec.json @@ -0,0 +1,23 @@ +{ + "name": "libindy-objc", + "version": "1.2.0", + "summary": "Summary TODO.", + "homepage": "TODO", + "license": { + "type": "Apache License 2.0", + "file": "LICENSE" + }, + "authors": { + "Daniel Hardman": "daniel.hardman@evernym.com" + }, + "source": { + "http": "https://repo.sovrin.org/ios/libindy/stable/indy-objc/1.2.0/libindy-objc.zip" + }, + "platforms": { + "ios": "10.0" + }, + "ios": { + "vendored_frameworks": "libindy-objc/Indy.framework" + }, + "module_name": "Indy" +} diff --git a/Specs/libindy/1.2.0/libindy.podspec.json b/Specs/libindy/1.2.0/libindy.podspec.json new file mode 100644 index 0000000000..b5d775047b --- /dev/null +++ b/Specs/libindy/1.2.0/libindy.podspec.json @@ -0,0 +1,23 @@ +{ + "name": "libindy", + "version": "1.2.0", + "summary": "Summary TODO.", + "description": "Description TODO.", + "homepage": "TODO", + "license": { + "type": "Apache License 2.0", + "file": "LICENSE" + }, + "authors": { + "Daniel Hardman": "daniel.hardman@evernym.com" + }, + "platforms": { + "ios": "10.0" + }, + "source": { + "http": "https://repo.sovrin.org/ios/libindy/stable/libindy-core/1.2.0/libindy.tar.gz" + }, + "source_files": "*.h", + "vendored_libraries": "*.a", + "requires_arc": false +} From aa316edf80b5b6cdbdb9c2677b3519338eb2115f Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Tue, 9 Jan 2018 17:36:26 +0300 Subject: [PATCH 12/14] Disable protocol version support in libindy for working with previous stable of Nodes. TBD: only for RC branch, should be reversed before merge to master. Signed-off-by: Sergey Minaev --- libindy/src/services/ledger/types.rs | 4 ++++ libindy/tests/demo.rs | 1 + libindy/tests/ledger.rs | 32 +++++++++++----------------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/libindy/src/services/ledger/types.rs b/libindy/src/services/ledger/types.rs index 3de15bf1d1..3509bc9e2b 100644 --- a/libindy/src/services/ledger/types.rs +++ b/libindy/src/services/ledger/types.rs @@ -22,6 +22,10 @@ pub struct Request { pub req_id: u64, pub identifier: String, pub operation: T, + #[cfg(not(test))] + #[serde(skip_serializing)] + pub protocol_version: u64, + #[cfg(test)] pub protocol_version: u64, #[serde(skip_serializing_if = "Option::is_none")] pub signature: Option diff --git a/libindy/tests/demo.rs b/libindy/tests/demo.rs index 25fc73ccb4..22062b6691 100644 --- a/libindy/tests/demo.rs +++ b/libindy/tests/demo.rs @@ -708,6 +708,7 @@ fn ledger_demo_works() { req_id: u64, identifier: String, operation: Operation, + #[serde(skip_serializing)] protocol_version: u64, #[serde(skip_serializing_if = "Option::is_none")] signature: Option, diff --git a/libindy/tests/ledger.rs b/libindy/tests/ledger.rs index 291af80048..455b2f0887 100644 --- a/libindy/tests/ledger.rs +++ b/libindy/tests/ledger.rs @@ -280,8 +280,7 @@ mod high_cases { \"operation\":{{\ \"dest\":\"{}\",\ \"type\":\"1\"\ - }},\ - \"protocolVersion\":1", IDENTIFIER, DEST); + }}", IDENTIFIER, DEST); let nym_request = LedgerUtils::build_nym_request(&IDENTIFIER, &DEST, None, None, None).unwrap(); assert!(nym_request.contains(&expected_result)); @@ -302,8 +301,7 @@ mod high_cases { \"role\":\"2\",\ \"type\":\"1\",\ \"verkey\":\"{}\"\ - }},\ - \"protocolVersion\":1", IDENTIFIER, alias, DEST, verkey); + }}", IDENTIFIER, alias, DEST, verkey); let nym_request = LedgerUtils::build_nym_request(&IDENTIFIER, &DEST, Some(verkey), Some(alias), Some(role)).unwrap(); assert!(nym_request.contains(&expected_result)); @@ -318,8 +316,7 @@ mod high_cases { \"dest\":\"{}\",\ \"role\":null,\ \"type\":\"1\"\ - }},\ - \"protocolVersion\":1", IDENTIFIER, DEST); + }}", IDENTIFIER, DEST); let nym_request = LedgerUtils::build_nym_request(&IDENTIFIER, &DEST, None, None, Some("")).unwrap(); assert!(nym_request.contains(&expected_result)); @@ -333,8 +330,7 @@ mod high_cases { \"operation\":{{\ \"type\":\"105\",\ \"dest\":\"{}\"\ - }},\ - \"protocolVersion\":1", IDENTIFIER, DEST); + }}", IDENTIFIER, DEST); let get_nym_request = LedgerUtils::build_get_nym_request(&IDENTIFIER, &DEST).unwrap(); assert!(get_nym_request.contains(&expected_result)); @@ -421,8 +417,7 @@ mod high_cases { \"type\":\"100\",\ \"dest\":\"{}\",\ \"raw\":\"{{\\\"endpoint\\\":{{\\\"ha\\\":\\\"127.0.0.1:5555\\\"}}}}\"\ - }},\ - \"protocolVersion\":1", IDENTIFIER, DEST); + }}", IDENTIFIER, DEST); let attrib_request = LedgerUtils::build_attrib_request(&IDENTIFIER, &DEST, None, Some(ATTRIB_RAW_DATA), None).unwrap(); assert!(attrib_request.contains(&expected_result)); @@ -446,8 +441,7 @@ mod high_cases { \"type\":\"104\",\ \"dest\":\"{}\",\ \"raw\":\"{}\"\ - }},\ - \"protocolVersion\":1", IDENTIFIER, DEST, raw); + }}", IDENTIFIER, DEST, raw); let get_attrib_request = LedgerUtils::build_get_attrib_request(&IDENTIFIER, &DEST, raw).unwrap(); assert!(get_attrib_request.contains(&expected_result)); @@ -510,7 +504,7 @@ mod high_cases { #[test] #[cfg(feature = "local_nodes_pool")] fn indy_build_schema_requests_works_for_correct_data_json() { - let expected_result = r#""operation":{"type":"101","data":{"name":"name","version":"1.0","attr_names":["name","male"]}},"protocolVersion":1"#; + let expected_result = r#""operation":{"type":"101","data":{"name":"name","version":"1.0","attr_names":["name","male"]}}"#; let schema_request = LedgerUtils::build_schema_request(IDENTIFIER, SCHEMA_DATA).unwrap(); assert!(schema_request.contains(expected_result)); @@ -519,7 +513,7 @@ mod high_cases { #[test] #[cfg(feature = "local_nodes_pool")] fn indy_build_get_schema_requests_works_for_correct_data_json() { - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"107","dest":"{}","data":{{"name":"name","version":"1.0"}}}},"protocolVersion":1"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"107","dest":"{}","data":{{"name":"name","version":"1.0"}}}}"#, IDENTIFIER, DEST); let get_schema_request = LedgerUtils::build_get_schema_request(IDENTIFIER, DEST, GET_SCHEMA_DATA).unwrap(); @@ -578,7 +572,7 @@ mod high_cases { #[test] fn indy_build_node_request_works_for_correct_data_json() { - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"0","dest":"{}","data":{{"node_ip":"10.0.0.100","node_port":1,"client_ip":"10.0.0.100","client_port":1,"alias":"some","services":["VALIDATOR"],"blskey":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"}}}},"protocolVersion":1"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"0","dest":"{}","data":{{"node_ip":"10.0.0.100","node_port":1,"client_ip":"10.0.0.100","client_port":1,"alias":"some","services":["VALIDATOR"],"blskey":"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"}}}}"#, IDENTIFIER, DEST); let node_request = LedgerUtils::build_node_request(IDENTIFIER, DEST, NODE_DATA).unwrap(); @@ -641,7 +635,7 @@ mod high_cases { fn indy_build_claim_def_request_works_for_correct_data_json() { let data = r#"{"primary":{"n":"1","s":"2","rms":"3","r":{"name":"1"},"rctxt":"1","z":"1"}}"#; - let expected_result = format!(r#""identifier":"{}","operation":{{"ref":{},"data":{{"primary":{{"n":"1","s":"2","rms":"3","r":{{"name":"1"}},"rctxt":"1","z":"1"}},"revocation":{{}}}},"type":"102","signature_type":"{}"}},"protocolVersion":1"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"ref":{},"data":{{"primary":{{"n":"1","s":"2","rms":"3","r":{{"name":"1"}},"rctxt":"1","z":"1"}},"revocation":{{}}}},"type":"102","signature_type":"{}"}}"#, IDENTIFIER, SEQ_NO, SIGNATURE_TYPE); let claim_def_request = LedgerUtils::build_claim_def_txn(IDENTIFIER, SEQ_NO, SIGNATURE_TYPE, &data).unwrap(); @@ -652,7 +646,7 @@ mod high_cases { fn indy_build_get_claim_def_request_works() { let origin = "origin"; - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"108","ref":{},"signature_type":"{}","origin":"{}"}},"protocolVersion":1"#, + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"108","ref":{},"signature_type":"{}","origin":"{}"}}"#, IDENTIFIER, SEQ_NO, SIGNATURE_TYPE, origin); let get_claim_def_request = LedgerUtils::build_get_claim_def_txn(IDENTIFIER, SEQ_NO, SIGNATURE_TYPE, origin).unwrap(); @@ -735,7 +729,7 @@ mod high_cases { #[test] fn indy_build_get_txn_request() { - let expected_result = format!(r#""identifier":"{}","operation":{{"type":"3","data":{}}},"protocolVersion":1"#, IDENTIFIER, SEQ_NO); + let expected_result = format!(r#""identifier":"{}","operation":{{"type":"3","data":{}}}"#, IDENTIFIER, SEQ_NO); let get_txn_request = LedgerUtils::build_get_txn_request(IDENTIFIER, SEQ_NO).unwrap(); assert!(get_txn_request.contains(&expected_result)); @@ -1078,7 +1072,7 @@ mod medium_cases { let get_nym_response_without_role: Reply = serde_json::from_str(&get_nym_response_without_role).unwrap(); let get_nym_response_data_without_role: GetNymResultData = serde_json::from_str(&get_nym_response_without_role.result.data.unwrap()).unwrap(); - assert!(get_nym_response_data_without_role.role.is_none()); + assert_eq!(get_nym_response_data_without_role.role.clone().unwrap_or("".to_string()), "".to_string()); assert_ne!(get_nym_response_data_without_role.role, get_nym_response_data_with_role.role); PoolUtils::close(pool_handle).unwrap(); From 15fc1d4992d91bb19638e286f5b17a24f1fd5aff Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Wed, 10 Jan 2018 13:55:04 +0300 Subject: [PATCH 13/14] [ios] Add keyForLocalDid to the wrapper. Signed-off-by: Sergey Minaev --- libindy/include/indy_signus.h | 2 +- wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.h | 4 ++++ wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.mm | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libindy/include/indy_signus.h b/libindy/include/indy_signus.h index 791127e505..fd226a7895 100644 --- a/libindy/include/indy_signus.h +++ b/libindy/include/indy_signus.h @@ -139,6 +139,7 @@ extern "C" { /// /// #Params /// command_handle: Command handle to map callback to caller context. + /// pool_handle: Pool handle to resolve information from the ledger. /// wallet_handle: Wallet handle (created by open_wallet). /// did - The DID to resolve key. /// cb: Callback that takes command result as parameter. @@ -192,7 +193,6 @@ extern "C" { /// Wallet* /// Crypto* extern indy_error_t indy_key_for_local_did(indy_handle_t command_handle, - indy_handle_t pool_handle, indy_handle_t wallet_handle, const char *const did, diff --git a/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.h b/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.h index 8934a4651e..ebc3d08228 100644 --- a/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.h +++ b/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.h @@ -101,6 +101,10 @@ walletHandle:(IndyHandle)walletHandle completion:(void (^)(NSError *error, NSString *key))completion; ++ (void)keyForLocalDid:(NSString *)did + walletHandle:(IndyHandle)walletHandle + completion:(void (^)(NSError *error, NSString *key))completion; + + (void)setEndpointAddress:(NSString *)address transportKey:(NSString *)transportKey forDid:(NSString *)did walletHandle:(IndyHandle)walletHandle completion:(void (^)(NSError *error))completion; + (void)getEndpointForDid:(NSString *)did diff --git a/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.mm b/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.mm index 64e38e9ce3..d1fc205fc9 100644 --- a/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.mm +++ b/wrappers/ios/libindy-pod/Indy/Wrapper/IndySignus.mm @@ -85,6 +85,16 @@ + (void)keyForDid:(NSString *)did [[IndyCallbacks sharedInstance] completeStr:completion forHandle:handle ifError:ret]; } ++ (void)keyForLocalDid:(NSString *)did + walletHandle:(IndyHandle)walletHandle + completion:(void (^)(NSError *error, NSString *key))completion +{ + indy_handle_t handle = [[IndyCallbacks sharedInstance] createCommandHandleFor:completion]; + indy_error_t ret = indy_key_for_local_did(handle, walletHandle, [did UTF8String], IndyWrapperCommon3PSCallback); + + [[IndyCallbacks sharedInstance] completeStr:completion forHandle:handle ifError:ret]; +} + + (void)setEndpointAddress:(NSString *)address transportKey:(NSString *)transportKey forDid:(NSString *)did From f8dd4c8e92b49bef9eb10ccbf2a50e164307c530 Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Wed, 10 Jan 2018 16:39:45 +0300 Subject: [PATCH 14/14] [ios] Increment version libindy in dependency. Signed-off-by: Sergey Minaev --- wrappers/ios/libindy-pod/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/ios/libindy-pod/Podfile b/wrappers/ios/libindy-pod/Podfile index bf0a3b29af..36688edd2e 100644 --- a/wrappers/ios/libindy-pod/Podfile +++ b/wrappers/ios/libindy-pod/Podfile @@ -9,7 +9,7 @@ def appPods pod 'libzmq-pw',"4.2.2" pod 'OpenSSL' pod 'milagro', "3.0.0" - pod 'libindy', "1.1.0" + pod 'libindy', "1.2.0" end target 'Indy-demo' do