public async Task StartSession_WithAllTimeZones(ApiKeySyncanoClient client) { //given var timeZones = TimeZoneInfo.GetSystemTimeZones(); var sessionIds = new List<string>(); //when foreach (var timeZoneInfo in timeZones) { try { sessionIds.Add(await client.StartSession(timeZoneInfo)); client.ClearSession(); } catch(ArgumentException) { } } //then foreach (var sessionId in sessionIds) { sessionId.ShouldNotBeNull(); } }
public async Task StartSession_WithUtcTimezone(ApiKeySyncanoClient client) { //when var result = await client.StartSession(TimeZoneInfo.Utc); //then result.ShouldNotBeNull(); }
public async Task New_BackendType_CreatesNewApiKey(ApiKeySyncanoClient client) { //given var description = "apiKey description"; //when var apiKey = await client.New(description, ApiKeyType.Backend, TestData.RoleId); //then apiKey.ShouldNotBeNull(); apiKey.Description.ShouldEqual(description); //cleanup await client.Delete(apiKey.Id); }
public async Task Delete_WithInvalidApiKey_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.Delete("abcde123"); throw new Exception("Delete should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<SyncanoException>(); } }
public async Task Delete_WithNullApiKey_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.Delete(null); throw new Exception("Delete should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task Delete_UserType_DeletesApiKey(ApiKeySyncanoClient client) { //given var description = "apiKey description"; var apiKey = await client.New(description, ApiKeyType.User); //when var result = await client.Delete(apiKey.Id); //then result.ShouldBeTrue(); }
public async Task Deauthorize_WithNullApiKeyId_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.Deauthorize(null, ApiKeyPermission.AccessSync); throw new Exception("Deauthorize should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task Deauthorize_WithSubscribePermission(ApiKeySyncanoClient client) { //given var description = "apiKey description"; var apiKey = await client.New(description, ApiKeyType.User); await client.Authorize(apiKey.Id, ApiKeyPermission.SendNotification); //when var result = await client.Deauthorize(apiKey.Id, ApiKeyPermission.SendNotification); //then result.ShouldBeTrue(); //cleanup await client.Delete(apiKey.Id); }
public async Task New_WithRoleIdAndUserType_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.New("description", ApiKeyType.User, TestData.RoleId); throw new Exception("New should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<ArgumentException>(); } }
public async Task Update_WithInvalidApiKeyId_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.UpdateDescription("description", "abcde123"); throw new Exception("UpdateDescription should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<SyncanoException>(); } }
public async Task Update_WithNullDescription_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.UpdateDescription(null); throw new Exception("UpdateDescription should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task Update_UpdatesApiKey(ApiKeySyncanoClient client) { //given var description = "apiKey description"; var newDescription = "new apiKey description"; var apiKey = await client.New(description, ApiKeyType.Backend, TestData.RoleId); //when apiKey = await client.UpdateDescription(newDescription, apiKey.Id); //then apiKey.ShouldNotBeNull(); apiKey.Description.ShouldEqual(newDescription); //cleanup await client.Delete(apiKey.Id); }
public async Task GetOne_WithoutApiClientId_CreatesApiKeysList(ApiKeySyncanoClient client) { //when var result = await client.GetOne(); //then result.ShouldNotBeNull(); result.ApiKeyValue.ShouldEqual(TestData.BackendAdminApiKey); result.Type.ShouldEqual(ApiKeyType.Backend); }
public async Task Get_GetsApiKeysList(ApiKeySyncanoClient client) { //when var result = await client.Get(); //then result.ShouldNotBeNull(); result.Count.ShouldEqual(2); result.Any(a => a.ApiKeyValue == TestData.BackendAdminApiKey).ShouldBeTrue(); }
public async Task New_WithInvalidRoleId_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.New("description", ApiKeyType.Backend, "9999"); throw new Exception("New should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<SyncanoException>(); } }
public async Task Authorize_WithAccessSyncPermission(ApiKeySyncanoClient client) { //given var description = "apiKey description"; var apiKey = await client.New(description, ApiKeyType.User); //when var result = await client.Authorize(apiKey.Id, ApiKeyPermission.AccessSync); //then result.ShouldBeTrue(); //cleanup await client.Delete(apiKey.Id); }
public async Task New_WithNullDescription_ThrowsException(ApiKeySyncanoClient client) { try { //when await client.New(null, roleId: TestData.RoleId); throw new Exception("New should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }