File tree 3 files changed +15
-4
lines changed
3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using Coder . Desktop . CoderSdk . Coder ;
2
3
3
4
namespace Coder . Desktop . App . Models ;
4
5
@@ -14,7 +15,7 @@ public enum CredentialState
14
15
Valid ,
15
16
}
16
17
17
- public class CredentialModel
18
+ public class CredentialModel : ICoderApiClientCredentialProvider
18
19
{
19
20
public CredentialState State { get ; init ; } = CredentialState . Unknown ;
20
21
@@ -33,4 +34,14 @@ public CredentialModel Clone()
33
34
Username = Username ,
34
35
} ;
35
36
}
37
+
38
+ public CoderApiClientCredential ? GetCoderApiClientCredential ( )
39
+ {
40
+ if ( State != CredentialState . Valid ) return null ;
41
+ return new CoderApiClientCredential
42
+ {
43
+ ApiToken = ApiToken ! ,
44
+ CoderUrl = CoderUrl ! ,
45
+ } ;
46
+ }
36
47
}
Original file line number Diff line number Diff line change @@ -78,8 +78,7 @@ private async Task Refresh()
78
78
_dirty = false ;
79
79
}
80
80
81
- var client = _clientFactory . Create ( credentials . CoderUrl ! . ToString ( ) ) ;
82
- client . SetSessionToken ( credentials . ApiToken ! ) ;
81
+ var client = _clientFactory . Create ( credentials ) ;
83
82
using var timeoutSrc = new CancellationTokenSource ( TimeSpan . FromSeconds ( 10 ) ) ;
84
83
var connInfo = await client . GetAgentConnectionInfoGeneric ( timeoutSrc . Token ) ;
85
84
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ public void SetupMocks()
26
26
_mCoderApiClientFactory = new Mock < ICoderApiClientFactory > ( MockBehavior . Strict ) ;
27
27
_mCredentialManager = new Mock < ICredentialManager > ( MockBehavior . Strict ) ;
28
28
_mCoderApiClient = new Mock < ICoderApiClient > ( MockBehavior . Strict ) ;
29
- _mCoderApiClientFactory . Setup ( m => m . Create ( coderUrl ) ) . Returns ( _mCoderApiClient . Object ) ;
29
+ _mCoderApiClientFactory . Setup ( m => m . Create ( It . IsAny < ICoderApiClientCredentialProvider > ( ) ) )
30
+ . Returns ( _mCoderApiClient . Object ) ;
30
31
}
31
32
32
33
private Mock < ICoderApiClientFactory > _mCoderApiClientFactory ;
You can’t perform that action at this time.
0 commit comments