Exemplo n.º 1
0
        public async Task <IEnumerable <IPayload> > DecryptAndExtractPayloads(Task <Stream> encryptedZipStream)
        {
            var payloads = new List <StreamPayload>();

            using (var stream = await Decrypt(encryptedZipStream).ConfigureAwait(false))
            {
                var asiceReader = new AsiceReader().Read(stream);

                foreach (var entry in asiceReader.Entries)
                {
                    using (var entryStream = entry.OpenStream())
                    {
                        var memoryStream = new MemoryStream();

                        await entryStream.CopyToAsync(memoryStream).ConfigureAwait(false);

                        var payload = new StreamPayload(memoryStream, entry.FileName);

                        payloads.Add(payload);
                    }
                }
            }

            return(payloads);
        }
Exemplo n.º 2
0
        public static void CreateCustomPayload(FiksRequest fiksRequest, List <IPayload> payloads)
        {
            IPayload payload = new StreamPayload(new MemoryStream(fiksRequest.CustomPayloadFile.Payload),
                                                 fiksRequest.CustomPayloadFile.Filename);

            payloads.Add(payload);
        }
Exemplo n.º 3
0
        public void AsiceBuilderIsDisposed()
        {
            var sut = _fixture.CreateSut();

            var payload = new StreamPayload(_fixture.RandomStream, "filename.file");

            var outStream = sut.Encrypt(null, new List <IPayload> {
                payload
            });

            _fixture.AsiceBuilderMock.Verify(_ => _.Dispose());
        }
Exemplo n.º 4
0
        public void CallsAsiceBuilderAddFile()
        {
            var sut = _fixture.CreateSut();

            var payload = new StreamPayload(_fixture.RandomStream, "filename.file");

            var outStream = sut.Encrypt(null, new List <IPayload> {
                payload
            });

            _fixture.AsiceBuilderMock.Verify(_ => _.AddFile(payload.Payload, payload.Filename));
        }
Exemplo n.º 5
0
        public void ReturnsANonNullStream()
        {
            var sut = _fixture.CreateSut();

            var payload = new StreamPayload(_fixture.RandomStream, "filename.file");

            var outStream = sut.Encrypt(null, new List <IPayload> {
                payload
            });

            outStream.Should().NotBeNull();
        }
Exemplo n.º 6
0
        private void Stream_OnMessageReceived(MessageReceivedEventArgs message)
        {
            StreamPayload payload = JsonConvert.DeserializeObject <StreamPayload>(message.Data);

            if (payload != null &&
                payload.Data != null &&
                payload.Stream == streamName)
            {
                MarketDiffData data = JsonConvert.DeserializeObject <MarketDiffData>(payload.Data.ToString());

                OnDataReceived?.Invoke(data);
            }
        }
Exemplo n.º 7
0
        public void CallsEncrypt()
        {
            var expectedOutputString = "myStringToSend";
            var expectedZipStream    = new MemoryStream(Encoding.UTF8.GetBytes(expectedOutputString));

            var sut = _fixture.WithContentAsZipStreamed(expectedZipStream).CreateSut();

            var payload = new StreamPayload(_fixture.RandomStream, "filename.file");

            var outStream = sut.Encrypt(null, new List <IPayload> {
                payload
            });

            _fixture.EncryptionServiceMock.Verify(
                _ => _.Encrypt(
                    It.IsAny <Stream>(),
                    It.IsAny <Stream>()));
        }
Exemplo n.º 8
0
        public void ReturnsExpectedStream()
        {
            var expectedOutputString = "myStringToSend";
            var expectedOutStream    = new MemoryStream(Encoding.UTF8.GetBytes(expectedOutputString));

            var sut = _fixture.WithContentAsEncryptedZipStreamed(expectedOutStream).CreateSut();

            var payload = new StreamPayload(_fixture.RandomStream, "filename.file");

            var outStream = sut.Encrypt(null, new List <IPayload> {
                payload
            });

            var outStreamBytes = new byte[outStream.Length];

            outStream.Read(outStreamBytes);
            var outputAsString = Encoding.UTF8.GetString(outStreamBytes);

            outputAsString.Should().Be(expectedOutputString);
        }