Skip to content

Commit d31265b

Browse files
Implement DoNotRunFederatedTestsAttribute to gate federated tests (#5418)
* fix pipeline * Update IgnoreFederatedTests.cs * undo --------- Co-authored-by: Gladwin Johnson <[email protected]>
1 parent 53da7c3 commit d31265b

File tree

7 files changed

+89
-7
lines changed

7 files changed

+89
-7
lines changed

tests/Directory.Build.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
<PropertyGroup Condition="'$(PipelineType)' == 'OneBranch'">
77
<DefineConstants>$(DefineConstants);ONEBRANCH_BUILD</DefineConstants>
88
</PropertyGroup>
9+
<PropertyGroup Condition="'$(MSAL_SKIP_FEDERATED_TESTS)' == 'True'">
10+
<DefineConstants>$(DefineConstants);IGNORE_FEDERATED</DefineConstants>
11+
</PropertyGroup>
912
</Project>

tests/Microsoft.Identity.Test.Integration.netcore/HeadlessTests/ClientCredentialsTests.NetFwk.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ public async Task RefreshOnIsEnabled(bool useRegional)
8989

9090
[DataTestMethod]
9191
[DataRow(Cloud.Public, TargetFrameworks.NetFx | TargetFrameworks.NetCore)]
92+
#if !IGNORE_FEDERATED
9293
[DataRow(Cloud.Adfs, TargetFrameworks.NetFx | TargetFrameworks.NetCore)]
93-
//[DataRow(Cloud.PPE, TargetFrameworks.NetFx)]
94+
#endif
9495
[DataRow(Cloud.Public, TargetFrameworks.NetCore, true)]
9596
//[DataRow(Cloud.Arlington)] - cert not setup
9697
public async Task WithCertificate_TestAsync(Cloud cloud, TargetFrameworks runOn, bool useAppIdUri = false)
@@ -101,9 +102,10 @@ public async Task WithCertificate_TestAsync(Cloud cloud, TargetFrameworks runOn,
101102

102103
[DataTestMethod]
103104
[DataRow(Cloud.Public, TargetFrameworks.NetCore)]
105+
#if !IGNORE_FEDERATED
104106
[DataRow(Cloud.Adfs, TargetFrameworks.NetFx)]
107+
#endif
105108
[DataRow(Cloud.Arlington, TargetFrameworks.NetCore)]
106-
//[DataRow(Cloud.PPE)] - secret not setup
107109
public async Task WithSecret_TestAsync(Cloud cloud, TargetFrameworks runOn)
108110
{
109111
runOn.AssertFramework();
@@ -112,8 +114,9 @@ public async Task WithSecret_TestAsync(Cloud cloud, TargetFrameworks runOn)
112114

113115
[DataTestMethod]
114116
[DataRow(Cloud.Public, TargetFrameworks.NetCore)]
117+
#if !IGNORE_FEDERATED
115118
[DataRow(Cloud.Adfs, TargetFrameworks.NetCore)]
116-
//[DataRow(Cloud.PPE, TargetFrameworks.NetCore)]
119+
#endif
117120
// [DataRow(Cloud.Arlington)] - cert not setup
118121
public async Task WithClientAssertion_Manual_TestAsync(Cloud cloud, TargetFrameworks runOn)
119122
{
@@ -123,8 +126,9 @@ public async Task WithClientAssertion_Manual_TestAsync(Cloud cloud, TargetFramew
123126

124127
[DataTestMethod]
125128
[DataRow(Cloud.Public, TargetFrameworks.NetFx)]
129+
#if !IGNORE_FEDERATED
126130
[DataRow(Cloud.Adfs, TargetFrameworks.NetFx)]
127-
//[DataRow(Cloud.PPE, TargetFrameworks.NetCore)]
131+
#endif
128132
// [DataRow(Cloud.Arlington)] - cert not setup
129133
public async Task WithClientAssertion_Wilson_TestAsync(Cloud cloud, TargetFrameworks runOn)
130134
{
@@ -143,7 +147,9 @@ public async Task WithClientClaims_ExtraClaims_TestAsync(Cloud cloud, TargetFram
143147

144148
[DataTestMethod]
145149
[DataRow(Cloud.Public, TargetFrameworks.NetFx)]
150+
#if !IGNORE_FEDERATED
146151
[DataRow(Cloud.Adfs, TargetFrameworks.NetCore)]
152+
#endif
147153
// [DataRow(Cloud.Arlington)] - cert not setup
148154
public async Task WithClientClaims_OverrideClaims_TestAsync(Cloud cloud, TargetFrameworks runOn)
149155
{
@@ -162,7 +168,9 @@ public async Task WithClientClaims_SendX5C_ExtraClaims_TestAsync(Cloud cloud, Ta
162168

163169
[DataTestMethod]
164170
[DataRow(Cloud.Public, TargetFrameworks.NetFx)]
171+
#if !IGNORE_FEDERATED
165172
[DataRow(Cloud.Adfs, TargetFrameworks.NetCore)]
173+
#endif
166174
// [DataRow(Cloud.Arlington)] - cert not setup
167175
public async Task WithClientClaims_SendX5C_OverrideClaims_TestAsync(Cloud cloud, TargetFrameworks runOn)
168176
{
@@ -223,12 +231,12 @@ public async Task ByRefreshTokenTestAsync()
223231
.WithAuthority(labResponse.Lab.Authority, "organizations")
224232
.BuildConcrete();
225233

226-
#pragma warning disable CS0618 // Type or member is obsolete
234+
#pragma warning disable CS0618 // Type or member is obsolete
227235
AuthenticationResult authResult = await msalPublicClient
228236
.AcquireTokenByUsernamePassword(s_scopes, labResponse.User.Upn, labResponse.User.GetOrFetchPassword())
229237
.ExecuteAsync(CancellationToken.None)
230238
.ConfigureAwait(false);
231-
#pragma warning restore CS0618
239+
#pragma warning restore CS0618
232240

233241
var confidentialApp = ConfidentialClientApplicationBuilder
234242
.Create(labResponse.App.AppId)

tests/Microsoft.Identity.Test.Integration.netcore/HeadlessTests/OnBehalfOfTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ public async Task OboAndClientCredentials_WithRegional_ReturnsCorrectTokens_Test
226226
}
227227

228228
[TestMethod]
229+
#if IGNORE_FEDERATED
230+
[Ignore]
231+
#endif
229232
public async Task WithMultipleUsers_TestAsync()
230233
{
231234
var aadUser1 = (await LabUserHelper.GetDefaultUserAsync().ConfigureAwait(false)).User;

tests/Microsoft.Identity.Test.Integration.netcore/HeadlessTests/UsernamePasswordIntegrationTests.NetFwk.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,29 @@ public async Task ARLINGTON_ROPC_AAD_CCA_Async()
8282

8383
[RunOn(TargetFrameworks.NetCore)]
8484
[TestCategory(TestCategories.Arlington)]
85+
#if IGNORE_FEDERATED
86+
[Ignore]
87+
#endif
8588
public async Task ARLINGTON_ROPC_ADFS_Async()
8689
{
8790
var labResponse = await LabUserHelper.GetArlingtonADFSUserAsync().ConfigureAwait(false);
8891
await RunHappyPathTestAsync(labResponse).ConfigureAwait(false);
8992
}
9093

9194
[RunOn(TargetFrameworks.NetCore)]
95+
#if IGNORE_FEDERATED
96+
[Ignore]
97+
#endif
9298
public async Task ROPC_ADFSv4Federated_Async()
9399
{
94100
var labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.AdfsV4, true).ConfigureAwait(false);
95101
await RunHappyPathTestAsync(labResponse).ConfigureAwait(false);
96102
}
97103

98104
[RunOn(TargetFrameworks.NetCore)]
105+
#if IGNORE_FEDERATED
106+
[Ignore]
107+
#endif
99108
public async Task ROPC_ADFSv4Federated_WithMetadata_Async()
100109
{
101110
var labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.AdfsV4, true).ConfigureAwait(false);
@@ -105,6 +114,9 @@ public async Task ROPC_ADFSv4Federated_WithMetadata_Async()
105114

106115
[RunOn(TargetFrameworks.NetCore)]
107116
[TestCategory(TestCategories.ADFS)]
117+
#if IGNORE_FEDERATED
118+
[Ignore]
119+
#endif
108120
public async Task AcquireTokenFromAdfsUsernamePasswordAsync()
109121
{
110122
LabResponse labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.ADFSv2019, true).ConfigureAwait(false);
@@ -182,7 +194,7 @@ public async Task AcquireTokenWithManagedUsernameIncorrectPasswordAsync()
182194
}
183195

184196
[RunOn(TargetFrameworks.NetCore)]
185-
public async Task AcquireTokenWithFederatedUsernameIncorrectPasswordAsync()
197+
public async Task AcquireTokenDefaultUserIncorrectPasswordAsync()
186198
{
187199
var labResponse = await LabUserHelper.GetDefaultUserAsync().ConfigureAwait(false);
188200
var user = labResponse.User;
@@ -475,6 +487,9 @@ public async Task Kerberos_ROPC_AAD_Async()
475487
}
476488

477489
[IgnoreOnOneBranch]
490+
#if IGNORE_FEDERATED
491+
[Ignore]
492+
#endif
478493
public async Task Kerberos_ROPC_ADFSv4Federated_Async()
479494
{
480495
var labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.AdfsV4, true).ConfigureAwait(false);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using Microsoft.VisualStudio.TestTools.UnitTesting;
10+
11+
namespace Microsoft.Identity.Test.Integration.Infrastructure
12+
{
13+
/// <summary>
14+
/// Ignores federated tests.
15+
/// </summary>
16+
internal class IgnoreFederatedTestsAttribute : TestMethodAttribute
17+
{
18+
public override TestResult[] Execute(ITestMethod testMethod)
19+
{
20+
#if IGNORE_FEDERATED
21+
return new[]
22+
{
23+
new TestResult
24+
{
25+
Outcome = UnitTestOutcome.Inconclusive,
26+
TestFailureException = new AssertInconclusiveException(
27+
$"Skipped on OneBranch pipeline")
28+
}
29+
};
30+
#else
31+
return base.Execute(testMethod);
32+
#endif
33+
}
34+
}
35+
}

tests/Microsoft.Identity.Test.Integration.netcore/SeleniumTests/DeviceCodeFlowIntegrationTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public async Task ArlingtonDeviceCodeFlowTestAsync()
6565
[TestMethod]
6666
[Timeout(2 * 60 * 1000)] // 2 min timeout
6767
[TestCategory(TestCategories.ADFS)]
68+
#if IGNORE_FEDERATED
69+
[Ignore]
70+
#endif
6871
public async Task DeviceCodeFlowAdfsTestAsync()
6972
{
7073
LabResponse labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.ADFSv2019, true).ConfigureAwait(false);
@@ -75,6 +78,9 @@ public async Task DeviceCodeFlowAdfsTestAsync()
7578
[TestMethod]
7679
[Timeout(2 * 60 * 1000)] // 2 min timeout
7780
[TestCategory(TestCategories.Arlington)]
81+
#if IGNORE_FEDERATED
82+
[Ignore]
83+
#endif
7884
public async Task ArlingtonDeviceCodeFlowAdfsTestAsync()
7985
{
8086
LabResponse labResponse = await LabUserHelper.GetArlingtonADFSUserAsync().ConfigureAwait(false);

tests/Microsoft.Identity.Test.Integration.netcore/SeleniumTests/InteractiveFlowTests.NetFwk.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public async Task Interactive_MsaUser_Async()
7171
}
7272

7373
[RunOn(TargetFrameworks.NetCore)]
74+
#if IGNORE_FEDERATED
75+
[Ignore]
76+
#endif
7477
public async Task Interactive_AdfsV4_FederatedAsync()
7578
{
7679
LabResponse labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.AdfsV4, true).ConfigureAwait(false);
@@ -87,6 +90,9 @@ public async Task InteractiveConsentPromptAsync()
8790
}
8891

8992
[RunOn(TargetFrameworks.NetCore)]
93+
#if IGNORE_FEDERATED
94+
[Ignore]
95+
#endif
9096
public async Task Interactive_AdfsV2019_FederatedAsync()
9197
{
9298
LabResponse labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.ADFSv2019, true).ConfigureAwait(false);
@@ -95,6 +101,9 @@ public async Task Interactive_AdfsV2019_FederatedAsync()
95101

96102
[RunOn(TargetFrameworks.NetCore)]
97103
[TestCategory(TestCategories.Arlington)]
104+
#if IGNORE_FEDERATED
105+
[Ignore]
106+
#endif
98107
public async Task Arlington_Interactive_AdfsV2019_FederatedAsync()
99108
{
100109
LabResponse labResponse = await LabUserHelper.GetArlingtonADFSUserAsync().ConfigureAwait(false);
@@ -156,6 +165,9 @@ public async Task Interactive_Arlington_MultiCloudSupport_AADAsync()
156165

157166
[RunOn(TargetFrameworks.NetCore)]
158167
[TestCategory(TestCategories.ADFS)]
168+
#if IGNORE_FEDERATED
169+
[Ignore]
170+
#endif
159171
public async Task Interactive_AdfsV2019_DirectAsync()
160172
{
161173
LabResponse labResponse = await LabUserHelper.GetAdfsUserAsync(FederationProvider.ADFSv2019, true).ConfigureAwait(false);

0 commit comments

Comments
 (0)