ImageConfigTests.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. using System.Text.Json.Nodes;
  4. namespace Microsoft.NET.Build.Containers.UnitTests;
  5. public class ImageConfigTests
  6. {
  7. private const string SampleImageConfig = """
  8. {
  9. "architecture": "amd64",
  10. "config": {
  11. "User": "app",
  12. "Env": [
  13. "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  14. "ASPNETCORE_URLS=http://+:80",
  15. "DOTNET_RUNNING_IN_CONTAINER=true",
  16. "DOTNET_VERSION=7.0.2",
  17. "ASPNET_VERSION=7.0.2"
  18. ],
  19. "Cmd": ["bash"],
  20. "Volumes": {
  21. "/var/log/": {}
  22. },
  23. "WorkingDir": "/app",
  24. "Entrypoint": null,
  25. "Labels": null,
  26. "StopSignal": "SIGTERM"
  27. },
  28. "created": "2023-02-04T08:14:52.000901321Z",
  29. "os": "linux",
  30. "rootfs": {
  31. "type": "layers",
  32. "diff_ids": [
  33. "sha256:bd2fe8b74db65d82ea10db97368d35b92998d4ea0e7e7dc819481fe4a68f64cf",
  34. "sha256:94100d1041b650c6f7d7848c550cd98c25d0bdc193d30692e5ea5474d7b3b085",
  35. "sha256:53c2a75a33c8f971b4b5036d34764373e134f91ee01d8053b4c3573c42e1cf5d",
  36. "sha256:49a61320e585180286535a2545be5722b09e40ad44c7c190b20ec96c9e42e4a3",
  37. "sha256:8a379cce2ac272aa71aa029a7bbba85c852ba81711d9f90afaefd3bf5036dc48"
  38. ]
  39. }
  40. }
  41. """;
  42. [InlineData("User")]
  43. [InlineData("Volumes")]
  44. [InlineData("StopSignal")]
  45. [Theory]
  46. public void PassesThroughPropertyEvenThoughPropertyIsntExplicitlyHandled(string property)
  47. {
  48. ImageConfig c = new(SampleImageConfig);
  49. JsonNode after = JsonNode.Parse(c.BuildConfig())!;
  50. JsonNode? prop = after["config"]?[property];
  51. Assert.NotNull(prop);
  52. }
  53. }