Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests to verify that the PaxTarEntry and PaxGlobalExtendedAttribu…
…tesTarEntry constructors that take an extended attributes dictionary, throw when a disallowed character is found.
  • Loading branch information
carlossanlop committed Apr 4, 2023
commit 5cd8c1fbf1f34d8575bbf53b42d1ba677d957ce6
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.IO;
using System.Linq;
using System.Collections.Generic;
using Xunit;

namespace System.Formats.Tar.Tests
Expand Down Expand Up @@ -36,6 +35,28 @@ public void Constructor_UnsupportedEntryTypes()
Assert.Throws<ArgumentException>(() => new PaxTarEntry(TarEntryType.GlobalExtendedAttributes, InitialEntryName));
}


[Theory]
[InlineData("\n", "value")]
[InlineData("=", "value")]
[InlineData("key", "\n")]
[InlineData("\nkey", "value")]
[InlineData("k\ney", "value")]
[InlineData("key\n", "value")]
[InlineData("=key", "value")]
[InlineData("ke=y", "value")]
[InlineData("key=", "value")]
[InlineData("key", "\nvalue")]
[InlineData("key", "val\nue")]
[InlineData("key", "value\n")]
public void Disallowed_ExtendedAttributes_SeparatorCharacters(string key, string value)
{
Dictionary<string, string> extendedAttribute = new Dictionary<string, string>() { { key, value } };

Assert.Throws<ArgumentException>(() => new PaxTarEntry(TarEntryType.RegularFile, InitialEntryName, extendedAttribute));
Assert.Throws < ArgumentException>(() => new PaxGlobalExtendedAttributesTarEntry(extendedAttribute));
}

[Fact]
public void SupportedEntryType_RegularFile()
{
Expand Down