Skip to content

Commit

Permalink
bitbucket: fix and test microsoft#651
Browse files Browse the repository at this point in the history
Issue-651 Basic fix and test to allow Bitbucket authentication to work again.
  • Loading branch information
mminns authored and whoisj committed Jun 7, 2018
1 parent 393fcaf commit 6ac305b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<NuGetPackageImportStamp />
</PropertyGroup>
<Import Project="..\test.props" />
<Import Project="..\..\test.props" />
<PropertyGroup>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
Expand All @@ -37,11 +36,16 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AuthorityTest.cs" />
<Compile Include="BitbucketAuthTests.cs" />
<Compile Include="AuthenticationTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitHub.Authentication\Src\GitHub.Authentication.csproj">
<Project>{CF306116-BBF0-4CC7-AFCE-A506AC4752CB}</Project>
<Name>GitHub.Authentication</Name>
</ProjectReference>
<ProjectReference Include="..\Bitbucket.Authentication\Bitbucket.Authentication.csproj">
<Project>{ee663736-5bad-4ca6-a4f8-99978925ad8a}</Project>
<Name>Bitbucket.Authentication</Name>
Expand Down
3 changes: 3 additions & 0 deletions Bitbucket.Authentication/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following set of attributes.
Expand Down Expand Up @@ -27,3 +28,5 @@
// as shown below: [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]

[assembly: InternalsVisibleTo("Bitbucket.Authentication.Test")]
35 changes: 35 additions & 0 deletions Bitbucket.Authentication/Test/AuthorityTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Atlassian.Bitbucket.Authentication;
using GitHub.Authentication;
using Microsoft.Alm.Authentication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Bitbucket.Authentication.Test
{
public class AuthorityTest
{
[Fact]
public async void VerifyAcquireTokenAcceptsValidAuthenticationResultTypes()
{
var context = RuntimeContext.Default;
var authority = new Authority(context);
var targetUri = new TargetUri("https://bitbucket.org");
var credentials = new Credential("a", "b");
var resultType = AuthenticationResultType.None;
var tokenScope = Atlassian.Bitbucket.Authentication.TokenScope.None;

var values = Enum.GetValues(typeof(AuthenticationResultType)).Cast<AuthenticationResultType>();
values.ToList().ForEach(async _ =>
{
var token = await authority.AcquireToken(targetUri, credentials, resultType, tokenScope);
Assert.NotNull(token);
});
}
}
}

0 comments on commit 6ac305b

Please sign in to comment.