Skip to content
This repository has been archived by the owner on Dec 28, 2017. It is now read-only.

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Mar 24, 2017
2 parents 786320a + bc8c200 commit 1343600
Show file tree
Hide file tree
Showing 28 changed files with 1,059 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ branches:
# Build Cache #
#---------------------------------#
cache:
- Source\packages -> Source\**\packages.config
- src\packages -> src\**\packages.config
- tools -> setup.cake
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MIT License

Copyright (c) 2017 BBT Software AG and contributors

Parts of the code are inspired by code from https://github.com/SonarSource-VisualStudio/sonar-scanner-msbuild
Copyright (c) 2015-2017 SonarSource SA and Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
7 changes: 4 additions & 3 deletions nuspec/nuget/Cake.Prca.PullRequests.Tfs.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
<authors>BBT Software AG</authors>
<owners>bbtsoftware, pascalberger, cake-contrib</owners>
<summary>TFS support for the Pull Request Code Analysis Addin for Cake Build Automation System</summary>
<description>The TFS / VSTS support for the Pull Request Code Analysis Addin for Cake allows you to write found issues to Team Foundation Server or Visual Studio Team Services pull requests.</description>
<description>The TFS / VSTS support for the Pull Request Code Analysis Addin for Cake allows you to write found issues as comments to Team Foundation Server or Visual Studio Team Services pull requests.</description>
<licenseUrl>https://github.com/cake-contrib/Cake.Prca.PullRequests.Tfs/blob/develop/LICENSE</licenseUrl>
<projectUrl>https://github.com/cake-contrib/Cake.Prca.PullRequests.Tfs</projectUrl>
<projectUrl>http://cake-contrib.github.io/Cake.Prca.Website</projectUrl>
<iconUrl>https://raw.githubusercontent.com/cake-build/graphics/aba74fb4cb5fe9454381af2cc70c870088229d5c/png/cake-medium.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright © 2017 BBT Software AG, Root/Zermatt, Switzerland</copyright>
<tags>Cake Script PullRequest CodeAnalysis Cake-Prca-PullRequestSystem TFS VSTS Linting</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Prca.PullRequests.Tfs/releases/tag/0.2.0</releaseNotes>
<dependencies>
<dependency id="Cake.Prca" version="[0.1,0.2)" />
<dependency id="Cake.Prca" version="[0.2,0.3)" />
</dependencies>
</metadata>
<files>
Expand Down
8 changes: 8 additions & 0 deletions src/Cake.Prca.PullRequests.Tfs.Tests.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Ruleset for Cake.Prca.PullRequests.Tfs test cases" Description="Rules valid for Cake.Prca.PullRequests.Tfs test cases" ToolsVersion="14.0">
<Include Path="Cake.Prca.PullRequests.Tfs.ruleset" Action="Default" />
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1652" Action="None" />
</Rules>
</RuleSet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
namespace Cake.Prca.PullRequests.Tfs.Tests.Authentication
{
using Shouldly;
using Tfs.Authentication;
using Xunit;

public class AuthenticationProviderTests
{
public sealed class TheAuthenticationNtlmMethod
{
[Fact]
public void Should_Return_PrcaNtlmCredentials_Object()
{
// Given / When
var credentials = AuthenticationProvider.AuthenticationNtlm();

// Then
credentials.ShouldBeOfType<PrcaNtlmCredentials>();
}
}

public sealed class TheAuthenticationBasicMethod
{
[Fact]
public void Should_Throw_If_User_Name_Is_Null()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationBasic(null, "foo"));

// Then
result.IsArgumentNullException("userName");
}

[Fact]
public void Should_Throw_If_User_Name_Is_Empty()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationBasic(string.Empty, "foo"));

// Then
result.IsArgumentOutOfRangeException("userName");
}

[Fact]
public void Should_Throw_If_User_Name_Is_WhiteSpace()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationBasic(" ", "foo"));

// Then
result.IsArgumentOutOfRangeException("userName");
}

[Fact]
public void Should_Throw_If_Password_Is_Null()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationBasic("foo", null));

// Then
result.IsArgumentNullException("password");
}

[Fact]
public void Should_Throw_If_Password_Is_Empty()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationBasic("foo", string.Empty));

// Then
result.IsArgumentOutOfRangeException("password");
}

[Fact]
public void Should_Throw_If_Password_Is_WhiteSpace()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationBasic("foo", " "));

// Then
result.IsArgumentOutOfRangeException("password");
}

[Fact]
public void Should_Return_PrcaBasicCredentials_Object()
{
// Given / When
var credentials = AuthenticationProvider.AuthenticationBasic("foo", "bar");

// Then
credentials.ShouldBeOfType<PrcaBasicCredentials>();
}

[Fact]
public void Should_Set_User_Name()
{
// Given
const string userName = "foo";

// When
var credentials = AuthenticationProvider.AuthenticationBasic(userName, "bar");

// Then
credentials.ShouldBeOfType<PrcaBasicCredentials>();
((PrcaBasicCredentials)credentials).UserName.ShouldBe(userName);
}

[Fact]
public void Should_Set_Password()
{
// Given
const string password = "bar";

// When
var credentials = AuthenticationProvider.AuthenticationBasic("foo", password);

// Then
credentials.ShouldBeOfType<PrcaBasicCredentials>();
((PrcaBasicCredentials)credentials).Password.ShouldBe(password);
}
}

public sealed class TheAuthenticationPersonalAccessTokenMethod
{
[Fact]
public void Should_Throw_If_Personal_Access_Token_Is_Null()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationPersonalAccessToken(null));

// Then
result.IsArgumentNullException("personalAccessToken");
}

[Fact]
public void Should_Throw_If_Personal_Access_Token_Is_Empty()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationPersonalAccessToken(string.Empty));

// Then
result.IsArgumentOutOfRangeException("personalAccessToken");
}

[Fact]
public void Should_Throw_If_Personal_Access_Token_Is_WhiteSpace()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationPersonalAccessToken(" "));

// Then
result.IsArgumentOutOfRangeException("personalAccessToken");
}

[Fact]
public void Should_Return_PrcaBasicCredentials_Object()
{
// Given / When
var credentials = AuthenticationProvider.AuthenticationPersonalAccessToken("foo");

// Then
credentials.ShouldBeOfType<PrcaBasicCredentials>();
}

[Fact]
public void Should_Set_Personal_Access_Token()
{
// Given
const string personalAccessToken = "foo";

// When
var credentials = AuthenticationProvider.AuthenticationPersonalAccessToken(personalAccessToken);

// Then
credentials.ShouldBeOfType<PrcaBasicCredentials>();
((PrcaBasicCredentials)credentials).UserName.ShouldBe(string.Empty);
((PrcaBasicCredentials)credentials).Password.ShouldBe(personalAccessToken);
}
}

public sealed class TheAuthenticationOAuthMethod
{
[Fact]
public void Should_Throw_If_Access_Token_Is_Null()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationOAuth(null));

// Then
result.IsArgumentNullException("accessToken");
}

[Fact]
public void Should_Throw_If_Access_Token_Is_Empty()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationOAuth(string.Empty));

// Then
result.IsArgumentOutOfRangeException("accessToken");
}

[Fact]
public void Should_Throw_If_Access_Token_Is_WhiteSpace()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationOAuth(" "));

// Then
result.IsArgumentOutOfRangeException("accessToken");
}

[Fact]
public void Should_Return_PrcaOAuthCredentials_Object()
{
// Given / When
var credentials = AuthenticationProvider.AuthenticationOAuth("foo");

// Then
credentials.ShouldBeOfType<PrcaOAuthCredentials>();
}

[Fact]
public void Should_Set_Access_Token()
{
// Given
const string accessToken = "foo";

// When
var credentials = AuthenticationProvider.AuthenticationOAuth(accessToken);

// Then
credentials.ShouldBeOfType<PrcaOAuthCredentials>();
((PrcaOAuthCredentials)credentials).AccessToken.ShouldBe(accessToken);
}
}

public sealed class TheAuthenticationAzureActiveDirectoryMethod
{
[Fact]
public void Should_Throw_If_User_Name_Is_Null()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationAzureActiveDirectory(null, "foo"));

// Then
result.IsArgumentNullException("userName");
}

[Fact]
public void Should_Throw_If_User_Name_Is_Empty()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationAzureActiveDirectory(string.Empty, "foo"));

// Then
result.IsArgumentOutOfRangeException("userName");
}

[Fact]
public void Should_Throw_If_User_Name_Is_WhiteSpace()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationAzureActiveDirectory(" ", "foo"));

// Then
result.IsArgumentOutOfRangeException("userName");
}

[Fact]
public void Should_Throw_If_Password_Is_Null()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationAzureActiveDirectory("foo", null));

// Then
result.IsArgumentNullException("password");
}

[Fact]
public void Should_Throw_If_Password_Is_Empty()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationAzureActiveDirectory("foo", string.Empty));

// Then
result.IsArgumentOutOfRangeException("password");
}

[Fact]
public void Should_Throw_If_Password_Is_WhiteSpace()
{
// Given / When
var result = Record.Exception(() => AuthenticationProvider.AuthenticationAzureActiveDirectory("foo", " "));

// Then
result.IsArgumentOutOfRangeException("password");
}

[Fact]
public void Should_Return_PrcaAadCredentials_Object()
{
// Given / When
var credentials = AuthenticationProvider.AuthenticationAzureActiveDirectory("foo", "bar");

// Then
credentials.ShouldBeOfType<PrcaAadCredentials>();
}

[Fact]
public void Should_Set_User_Name()
{
// Given
const string userName = "foo";

// When
var credentials = AuthenticationProvider.AuthenticationAzureActiveDirectory(userName, "bar");

// Then
credentials.ShouldBeOfType<PrcaAadCredentials>();
((PrcaAadCredentials)credentials).UserName.ShouldBe(userName);
}

[Fact]
public void Should_Set_Password()
{
// Given
const string password = "bar";

// When
var credentials = AuthenticationProvider.AuthenticationAzureActiveDirectory("foo", password);

// Then
credentials.ShouldBeOfType<PrcaAadCredentials>();
((PrcaAadCredentials)credentials).Password.ShouldBe(password);
}
}
}
}
Loading

0 comments on commit 1343600

Please sign in to comment.