GitHub Actions Runner

This commit is contained in:
Tingluo Huang
2019-10-10 00:52:42 -04:00
commit c8afc84840
1255 changed files with 198670 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
using System;
using GitHub.Runner.Common.Util;
using GitHub.Runner.Sdk;
using Xunit;
namespace GitHub.Runner.Common.Tests.Util
{
public class UrlUtilL0
{
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void GetCredentialEmbeddedUrl_NoUsernameAndPassword()
{
// Act.
Uri result = UrlUtil.GetCredentialEmbeddedUrl(new Uri("https://github.com/actions/runner.git"), string.Empty, string.Empty);
// Actual
Assert.Equal("https://github.com/actions/runner.git", result.AbsoluteUri);
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void GetCredentialEmbeddedUrl_NoUsername()
{
// Act.
Uri result = UrlUtil.GetCredentialEmbeddedUrl(new Uri("https://github.com/actions/runner.git"), string.Empty, "password123");
// Actual
Assert.Equal("https://emptyusername:password123@github.com/actions/runner.git", result.AbsoluteUri);
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void GetCredentialEmbeddedUrl_NoPassword()
{
// Act.
Uri result = UrlUtil.GetCredentialEmbeddedUrl(new Uri("https://github.com/actions/runner.git"), "user123", string.Empty);
// Actual
Assert.Equal("https://user123@github.com/actions/runner.git", result.AbsoluteUri);
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void GetCredentialEmbeddedUrl_HasUsernameAndPassword()
{
// Act.
Uri result = UrlUtil.GetCredentialEmbeddedUrl(new Uri("https://github.com/actions/runner.git"), "user123", "password123");
// Actual
Assert.Equal("https://user123:password123@github.com/actions/runner.git", result.AbsoluteUri);
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void GetCredentialEmbeddedUrl_UsernameAndPasswordEncoding()
{
// Act.
Uri result = UrlUtil.GetCredentialEmbeddedUrl(new Uri("https://github.com/actions/runner.git"), "user 123", "password 123");
// Actual
Assert.Equal("https://user%20123:password%20123@github.com/actions/runner.git", result.AbsoluteUri);
}
}
}