@@ -27,16 +27,26 @@ namespace Tests;
2727[ SuppressMessage ( "ReSharper" , "MethodHasAsyncOverload" ) ]
2828public class Tests
2929{
30+ #if DEBUG
31+ const string DefaultEndpoint = "localhost" ;
32+ const int DefaultPort = 5000 ;
33+ const bool DefaultUseTls = false ;
34+ #else
35+ const string DefaultEndpoint = "staging-internal.trinsic.cloud" ;
36+ const int DefaultPort = 443 ;
37+ const bool DefaultUseTls = true ;
38+ #endif
39+
3040 private readonly ITestOutputHelper _testOutputHelper ;
3141 private readonly ServiceOptions _options ;
3242
3343 public Tests ( ITestOutputHelper testOutputHelper ) {
3444 _testOutputHelper = testOutputHelper ;
3545
3646 _options = new ( ) {
37- ServerEndpoint = Environment . GetEnvironmentVariable ( "TEST_SERVER_ENDPOINT" ) ?? "localhost" ,
38- ServerPort = int . TryParse ( Environment . GetEnvironmentVariable ( "TEST_SERVER_PORT" ) , out var port ) ? port : 5000 ,
39- ServerUseTls = ! bool . TryParse ( Environment . GetEnvironmentVariable ( "TEST_SERVER_USE_TLS" ) , out var tls ) || tls
47+ ServerEndpoint = Environment . GetEnvironmentVariable ( "TEST_SERVER_ENDPOINT" ) ?? DefaultEndpoint ,
48+ ServerPort = int . TryParse ( Environment . GetEnvironmentVariable ( "TEST_SERVER_PORT" ) , out var port ) ? port : DefaultPort ,
49+ ServerUseTls = bool . TryParse ( Environment . GetEnvironmentVariable ( "TEST_SERVER_USE_TLS" ) , out var tls ) ? tls : DefaultUseTls
4050 } ;
4151
4252 _testOutputHelper . WriteLine ( $ "Testing endpoint: { _options . FormatUrl ( ) } ") ;
@@ -48,13 +58,10 @@ public Tests(ITestOutputHelper testOutputHelper) {
4858 [ Fact ( DisplayName = "Demo: wallet and credential sample" ) ]
4959 public async Task TestWalletService ( ) {
5060 // createAccountService() {
51- var providerService = new ProviderService ( _options ) ;
52- var accountService = new AccountService ( _options ) ;
53- var account = await accountService . SignInAsync ( new ( ) ) ;
54-
55- providerService . Options . AuthToken = account ;
56- var ecosystem = providerService . CreateEcosystem ( new ( ) { Name = $ "test-sdk-{ Guid . NewGuid ( ) : N} "} ) ;
57- var ecosystemId = ecosystem . Ecosystem . Id ;
61+ var providerService = new ProviderService ( _options . Clone ( ) ) ;
62+ var accountService = new AccountService ( _options . Clone ( ) ) ;
63+ var ( ecosystem , _) = providerService . CreateEcosystem ( new ( ) ) ;
64+ var ecosystemId = ecosystem . Id ;
5865 // }
5966
6067 // SETUP ACTORS
@@ -144,9 +151,9 @@ public async Task TestWalletService() {
144151 [ Fact ( DisplayName = "Demo: trust registries" ) ]
145152 public async Task TestTrustRegistry ( ) {
146153 // setup
147- var accountService = new AccountService ( _options ) ;
148- var account = await accountService . SignInAsync ( new ( ) ) ;
149- var service = new TrustRegistryService ( _options . CloneWithAuthToken ( account ) ) ;
154+ var providerService = new ProviderService ( _options . Clone ( ) ) ;
155+ var ( _ , authToken ) = await providerService . CreateEcosystemAsync ( new ( ) ) ;
156+ var service = new TrustRegistryService ( _options . CloneWithAuthToken ( authToken ) ) ;
150157
151158 // register issuer
152159 var register = service . RegisterIssuerAsync ( new ( ) {
@@ -203,15 +210,14 @@ public async Task EcosystemTests() {
203210 var service = new ProviderService ( _options . CloneWithAuthToken ( account ) ) ;
204211
205212 // test create ecosystem
206- var actualCreate = await service . CreateEcosystemAsync ( new ( ) {
213+ var ( actualCreate , _ ) = await service . CreateEcosystemAsync ( new ( ) {
207214 Description = "My ecosystem" ,
208- Name = $ "test-sdk-{ Guid . NewGuid ( ) : N} ",
209215 Uri = "https://example.com"
210216 } ) ;
211217
212218 actualCreate . Should ( ) . NotBeNull ( ) ;
213- actualCreate . Ecosystem . Id . Should ( ) . NotBeNull ( ) ;
214- actualCreate . Ecosystem . Id . Should ( ) . StartWith ( "urn:trinsic:ecosystems:" ) ;
219+ actualCreate . Id . Should ( ) . NotBeNull ( ) ;
220+ actualCreate . Id . Should ( ) . StartWith ( "urn:trinsic:ecosystems:" ) ;
215221 }
216222
217223 [ Fact ]
@@ -237,9 +243,8 @@ public async Task TestProtectUnprotectProfile() {
237243
238244 [ Fact ]
239245 public async Task TestInvitationIdSet ( ) {
240- var accountService = new AccountService ( _options ) ;
241- var profile = await accountService . SignInAsync ( new ( ) ) ;
242- var providerService = new ProviderService ( _options . CloneWithAuthToken ( profile ) ) ;
246+ var providerService = new ProviderService ( _options . Clone ( ) ) ;
247+ _ = await providerService . CreateEcosystemAsync ( new ( ) ) ;
243248
244249 var invitationResponse = await providerService . InviteParticipantAsync ( new ( ) ) ;
245250
@@ -272,9 +277,9 @@ public async Task TestGovernanceFrameworkUriParse() {
272277
273278 [ Fact ( DisplayName = "Demo: template management and credential issuance from template" ) ]
274279 public async Task DemoTemplatesWithIssuance ( ) {
275- var accountService = new AccountService ( _options ) ;
276- var profile = await accountService . SignInAsync ( new ( ) ) ;
277- var options = _options . CloneWithAuthToken ( profile ) ;
280+ var providerService = new ProviderService ( _options . Clone ( ) ) ;
281+ var ( _ , authToken ) = await providerService . CreateEcosystemAsync ( new ( ) ) ;
282+ var options = _options . CloneWithAuthToken ( authToken ) ;
278283
279284 var templateService = new TemplateService ( options ) ;
280285 var credentialService = new CredentialsService ( options ) ;
0 commit comments