43cf036113
As noted by @sixcorners at https://github.com/storj/storj/pull/3819#issuecomment-609025487, the Windows installer code incorrectly fails if the ca.key file is not present. The ca.key file should not be necessary for regular storage node usage, and in fact we recommend that users move the ca.key file to secure storage rather than keeping it on the node. I'm not sure how to run the tests, so I'll get a nod from the SNO Growth team before merging. Change-Id: Ib2fe236de5c75165644e880caa827a2a1a034c87 Co-authored-by: Stefan Benten <mail@stefan-benten.de>
82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO.Abstractions.TestingHelpers;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Storj;
|
|
|
|
namespace StorjTests
|
|
{
|
|
[TestClass]
|
|
public class ValidateIdentityDirTests
|
|
{
|
|
[TestMethod]
|
|
[ExpectedExceptionWithMessage(typeof(ArgumentException), "You must select an identity folder.")]
|
|
public void NullIdentityDir()
|
|
{
|
|
new CustomActionRunner().ValidateIdentityDir(null);
|
|
}
|
|
|
|
[TestMethod]
|
|
[ExpectedExceptionWithMessage(typeof(ArgumentException), "You must select an identity folder.")]
|
|
public void EmptyIdentityDir()
|
|
{
|
|
new CustomActionRunner().ValidateIdentityDir("");
|
|
}
|
|
|
|
[TestMethod]
|
|
[ExpectedExceptionWithMessage(typeof(ArgumentException), "Folder 'X:\\Some\\Nonexistent\\Folder' does not exist.")]
|
|
public void NonexistentIdentityDir()
|
|
{
|
|
new CustomActionRunner().ValidateIdentityDir("X:\\Some\\Nonexistent\\Folder");
|
|
}
|
|
|
|
[TestMethod]
|
|
[ExpectedExceptionWithMessage(typeof(ArgumentException), "File 'ca.cert' not found in the selected folder.")]
|
|
public void MissingCACertFile()
|
|
{
|
|
var fs = new MockFileSystem(new Dictionary<string, MockFileData>
|
|
{
|
|
{ @"X:\\Some\\Identity\\Folder\\identity.cert", new MockFileData("") },
|
|
{ @"X:\\Some\\Identity\\Folder\\identity.key", new MockFileData("") }
|
|
});
|
|
new CustomActionRunner(fs).ValidateIdentityDir("X:\\Some\\Identity\\Folder");
|
|
}
|
|
|
|
[TestMethod]
|
|
[ExpectedExceptionWithMessage(typeof(ArgumentException), "File 'identity.cert' not found in the selected folder.")]
|
|
public void MissingIdentityCertFile()
|
|
{
|
|
var fs = new MockFileSystem(new Dictionary<string, MockFileData>
|
|
{
|
|
{ @"X:\\Some\\Identity\\Folder\\ca.cert", new MockFileData("") },
|
|
{ @"X:\\Some\\Identity\\Folder\\identity.key", new MockFileData("") }
|
|
});
|
|
new CustomActionRunner(fs).ValidateIdentityDir("X:\\Some\\Identity\\Folder");
|
|
}
|
|
|
|
[TestMethod]
|
|
[ExpectedExceptionWithMessage(typeof(ArgumentException), "File 'identity.key' not found in the selected folder.")]
|
|
public void MissingIdentityKeyFile()
|
|
{
|
|
var fs = new MockFileSystem(new Dictionary<string, MockFileData>
|
|
{
|
|
{ @"X:\\Some\\Identity\\Folder\\ca.cert", new MockFileData("") },
|
|
{ @"X:\\Some\\Identity\\Folder\\identity.cert", new MockFileData("") }
|
|
});
|
|
new CustomActionRunner(fs).ValidateIdentityDir("X:\\Some\\Identity\\Folder");
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ValidIdentityDir()
|
|
{
|
|
var fs = new MockFileSystem(new Dictionary<string, MockFileData>
|
|
{
|
|
{ @"X:\\Some\\Identity\\Folder\\ca.cert", new MockFileData("") },
|
|
{ @"X:\\Some\\Identity\\Folder\\identity.cert", new MockFileData("") },
|
|
{ @"X:\\Some\\Identity\\Folder\\identity.key", new MockFileData("") },
|
|
});
|
|
new CustomActionRunner(fs).ValidateIdentityDir("X:\\Some\\Identity\\Folder");
|
|
}
|
|
}
|
|
}
|