public void NothingElseCalled_HashReturned1() { //Arrange FetchDirectiveBuilder builder = new FetchDirectiveBuilder(); string inputValue = "sha256-somehash"; //Act builder.AllowHash(inputValue); //Assert string result = builder.Build(); Assert.Equal(inputValue, result); }
public void DuplicateHashesAllowed_DuplicatesRemoved1() { //Arrange FetchDirectiveBuilder builder = new FetchDirectiveBuilder(); string inputValue = "sha256-somehash"; //Act builder.AllowHash(inputValue).AllowHash(inputValue); //Assert string result = builder.Build(); Assert.Equal(inputValue, result); }
public void SomethingElseCalled_AsteriskAdded() { //Arrange FetchDirectiveBuilder builder = new FetchDirectiveBuilder(); //Act builder.AllowUnsafeInline(); builder.AllowHash("sha265-somehash"); builder.AllowAny(); //Assert string result = builder.Build(); Assert.Equal("'unsafe-inline' sha265-somehash *", result); }
public void DuplicateHashesAllowed_DuplicatesRemoved2() { //Arrange FetchDirectiveBuilder builder = new FetchDirectiveBuilder(); string inputAlg = "sha256"; string inputHash = "somehash"; //Act builder.AllowHash(inputAlg, inputHash).AllowHash(inputAlg, inputHash); //Assert string result = builder.Build(); Assert.Equal($"{inputAlg}-{inputHash}", result); }
public void SomethingElseCalled_HashAdded1() { //Arrange FetchDirectiveBuilder builder = new FetchDirectiveBuilder(); string inputValue = "sha256-somehash"; //Act builder.AllowAny(); builder.AllowHash(inputValue); //Assert string result = builder.Build(); Assert.Equal($"{inputValue} *", result); }
public void NothingElseCalled_HashReturned2() { //Arrange FetchDirectiveBuilder builder = new FetchDirectiveBuilder(); string inputAlg = "sha256"; string inputHash = "somehash"; //Act builder.AllowHash(inputAlg, inputHash); //Assert string result = builder.Build(); Assert.Equal($"{inputAlg}-{inputHash}", result); }