20
20
using System . Collections . Generic ;
21
21
using Microsoft . WindowsAzure . Commands . ScenarioTest ;
22
22
using Xunit ;
23
+ using Microsoft . Azure . Commands . Common . Authentication . Abstractions ;
23
24
24
25
namespace Common . Authentication . Test
25
26
{
@@ -29,32 +30,28 @@ public class AuthenticationFactoryTests
29
30
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
30
31
public void VerifySubscriptionTokenCacheRemove ( )
31
32
{
33
+ AzureSessionInitializer . InitializeAzureSession ( ) ;
32
34
var authFactory = new AuthenticationFactory
33
35
{
34
36
TokenProvider = new MockAccessTokenProvider ( "testtoken" , "testuser" )
35
37
} ;
36
38
37
39
var subscriptionId = Guid . NewGuid ( ) ;
38
-
40
+ var account = new AzureAccount
41
+ {
42
+ Id = "testuser" ,
43
+ Type = AzureAccount . AccountType . User ,
44
+ } ;
45
+ account . SetTenants ( "123" ) ;
46
+ var sub = new AzureSubscription
47
+ {
48
+ Id = subscriptionId . ToString ( ) ,
49
+ } ;
50
+ sub . SetTenant ( "123" ) ;
39
51
var credential = authFactory . GetSubscriptionCloudCredentials ( new AzureContext
40
52
(
41
- new AzureSubscription
42
- {
43
- Id = subscriptionId ,
44
- Properties = new Dictionary < AzureSubscription . Property , string >
45
- {
46
- { AzureSubscription . Property . Tenants , "123" }
47
- }
48
- } ,
49
- new AzureAccount
50
- {
51
- Id = "testuser" ,
52
- Type = AzureAccount . AccountType . User ,
53
- Properties = new Dictionary < AzureAccount . Property , string >
54
- {
55
- { AzureAccount . Property . Tenants , "123" }
56
- }
57
- } ,
53
+ sub ,
54
+ account ,
58
55
AzureEnvironment . PublicEnvironments [ "AzureCloud" ]
59
56
) ) ;
60
57
@@ -66,40 +63,34 @@ public void VerifySubscriptionTokenCacheRemove()
66
63
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
67
64
public void VerifyValidateAuthorityFalseForOnPremise ( )
68
65
{
66
+ AzureSessionInitializer . InitializeAzureSession ( ) ;
69
67
var authFactory = new AuthenticationFactory
70
68
{
71
69
TokenProvider = new MockAccessTokenProvider ( "testtoken" , "testuser" )
72
70
} ;
73
71
74
72
var subscriptionId = Guid . NewGuid ( ) ;
73
+ var account = new AzureAccount
74
+ {
75
+ Id = "testuser" ,
76
+ Type = AzureAccount . AccountType . User ,
77
+ } ;
78
+ account . SetTenants ( "123" ) ;
79
+ var sub = new AzureSubscription
80
+ {
81
+ Id = subscriptionId . ToString ( ) ,
82
+ } ;
83
+ sub . SetTenant ( "123" ) ;
75
84
var context = new AzureContext
76
85
(
77
- new AzureSubscription
78
- {
79
- Id = subscriptionId ,
80
- Properties = new Dictionary < AzureSubscription . Property , string >
81
- {
82
- { AzureSubscription . Property . Tenants , "123" }
83
- }
84
- } ,
85
- new AzureAccount
86
- {
87
- Id = "testuser" ,
88
- Type = AzureAccount . AccountType . User ,
89
- Properties = new Dictionary < AzureAccount . Property , string >
90
- {
91
- { AzureAccount . Property . Tenants , "123" }
92
- }
93
- } ,
86
+ sub ,
87
+ account ,
94
88
new AzureEnvironment
95
89
{
96
90
Name = "Katal" ,
97
91
OnPremise = true ,
98
- Endpoints = new Dictionary < AzureEnvironment . Endpoint , string >
99
- {
100
- { AzureEnvironment . Endpoint . ActiveDirectory , "http://ad.com" } ,
101
- { AzureEnvironment . Endpoint . ActiveDirectoryServiceEndpointResourceId , "http://adresource.com" }
102
- }
92
+ ActiveDirectoryAuthority = "http://ad.com" ,
93
+ ActiveDirectoryServiceEndpointResourceId = "http://adresource.com"
103
94
}
104
95
) ;
105
96
0 commit comments