File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using Coder . Desktop . CoderSdk . Coder ;
23
34namespace Coder . Desktop . App . Models ;
45
@@ -14,7 +15,7 @@ public enum CredentialState
1415 Valid ,
1516}
1617
17- public class CredentialModel
18+ public class CredentialModel : ICoderApiClientCredentialProvider
1819{
1920 public CredentialState State { get ; init ; } = CredentialState . Unknown ;
2021
@@ -33,4 +34,14 @@ public CredentialModel Clone()
3334 Username = Username ,
3435 } ;
3536 }
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+ }
3647}
Original file line number Diff line number Diff line change @@ -78,8 +78,7 @@ private async Task Refresh()
7878 _dirty = false ;
7979 }
8080
81- var client = _clientFactory . Create ( credentials . CoderUrl ! . ToString ( ) ) ;
82- client . SetSessionToken ( credentials . ApiToken ! ) ;
81+ var client = _clientFactory . Create ( credentials ) ;
8382 using var timeoutSrc = new CancellationTokenSource ( TimeSpan . FromSeconds ( 10 ) ) ;
8483 var connInfo = await client . GetAgentConnectionInfoGeneric ( timeoutSrc . Token ) ;
8584
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ public void SetupMocks()
2626 _mCoderApiClientFactory = new Mock < ICoderApiClientFactory > ( MockBehavior . Strict ) ;
2727 _mCredentialManager = new Mock < ICredentialManager > ( MockBehavior . Strict ) ;
2828 _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 ) ;
3031 }
3132
3233 private Mock < ICoderApiClientFactory > _mCoderApiClientFactory ;
You can’t perform that action at this time.
0 commit comments