示例#1
0
        public ScaniiClientTests()
        {
            var serilogLogger = new LoggerConfiguration()
                                .WriteTo.Console()
                                .MinimumLevel.Is(LogEventLevel.Debug)
                                .CreateLogger();

            var provider = new SerilogLoggerProvider(serilogLogger);

            _logger = provider.CreateLogger("ScaniiClientTests");

            _logger.LogDebug("ctor");


            if (Environment.GetEnvironmentVariable("SCANII_CREDS") != null)
            {
                // ReSharper disable once PossibleNullReferenceException
                var credentials = Environment.GetEnvironmentVariable("SCANII_CREDS").Split(':');
                _key    = credentials[0];
                _secret = credentials[1];
            }

            Debug.Assert(_secret != null, nameof(_secret) + " != null");
            Debug.Assert(_key != null, nameof(_key) + " != null");

            _client = ScaniiClients.CreateDefault(_key, _secret, _logger, new HttpClient());
        }
示例#2
0
        static async Task Main(string[] args)
        {
            var client = ScaniiClients.CreateDefault(args[0], args[1]);
            var result = await client.Process("C:\foo.doc");

            Console.WriteLine($"findings: {result.Findings}");
        }
示例#3
0
 public async Task ShouldPingAllRegions()
 {
     foreach (var target in ScaniiTarget.All())
     {
         _logger.LogInformation("creating client for target {Target}", target.Endpoint);
         var client = ScaniiClients.CreateDefault(_key, _secret, target: target);
         Assert.IsTrue(await client.Ping());
     }
 }
示例#4
0
        public async Task ShouldCreatedUsableAuthTokens()
        {
            var token = await _client.CreateAuthToken(5);

            var client2 = ScaniiClients.CreateDefault(token.ResourceId);

            _logger.LogInformation("using token to process content");

            var result = await client2.Process(_eicarFile);

            Assert.NotNull(result.ResourceId);
            Assert.True(result.Findings.Contains(Finding));
            Assert.AreEqual(1, result.Findings.Count);
            Assert.AreEqual(_checksum, result.Checksum);
            Assert.NotNull(result.ContentLength);
            Assert.NotNull(result.CreationDate);
        }