public Node EnableRoomEncryption(EnableRoomEncryptionRequest request) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation request.MustNotNull(nameof(request)); request.DataRoomRescueKeyPassword.MustNotNullOrEmptyOrWhitespace(nameof(request.DataRoomRescueKeyPassword), true); request.Id.MustPositive(nameof(request.Id)); #endregion ApiUserKeyPair apiDataRoomRescueKey = null; if (request.DataRoomRescueKeyPassword != null) { try { UserKeyPair cryptoPair = Crypto.Sdk.Crypto.GenerateUserKeyPair(request.DataRoomRescueKeyPassword); apiDataRoomRescueKey = UserMapper.ToApiUserKeyPair(cryptoPair); } catch (CryptoException ce) { DracoonClient.Log.Debug(Logtag, $"Generation of user key pair failed with '{ce.Message}'!"); throw new DracoonCryptoException(CryptoErrorMapper.ParseCause(ce), ce); } } ApiEnableRoomEncryptionRequest apiEnableRoomEncryptionRequest = RoomMapper.ToApiEnableRoomEncryptionRequest(request, apiDataRoomRescueKey); IRestRequest restRequest = _client.Builder.PutEnableRoomEncryption(request.Id, apiEnableRoomEncryptionRequest); ApiNode result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PutEnableRoomEncryption); return(NodeMapper.FromApiNode(result)); }
public void ToApiEnableRoomEncryptionRequest() { // ARRANGE ApiEnableRoomEncryptionRequest expected = FactoryRoom.ApiEnableRoomEncryptionRequest; EnableRoomEncryptionRequest param = new EnableRoomEncryptionRequest(1234, expected.IsEncryptionEnabled) { DataRoomRescueKeyPassword = "******", UseDataSpaceRescueKey = expected.UseDataSpaceRescueKey, }; // ACT ApiEnableRoomEncryptionRequest actual = RoomMapper.ToApiEnableRoomEncryptionRequest(param, expected.DataRoomRescueKey); // ASSERT Assert.Equal(expected, actual, new ApiEnableRoomEncryptionRequestComparer()); }
internal static ApiEnableRoomEncryptionRequest ToApiEnableRoomEncryptionRequest(EnableRoomEncryptionRequest enableRoomEncryptionRequest, ApiUserKeyPair dataRoomRescueKey) { ApiEnableRoomEncryptionRequest apiEnableRoomEncryptionRequest = new ApiEnableRoomEncryptionRequest { IsEncryptionEnabled = enableRoomEncryptionRequest.IsEncryptionEnabled, UseDataSpaceRescueKey = enableRoomEncryptionRequest.UseDataSpaceRescueKey, DataRoomRescueKey = dataRoomRescueKey }; return(apiEnableRoomEncryptionRequest); }