forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookmarkResourceTests.cs
More file actions
83 lines (77 loc) · 3.9 KB
/
BookmarkResourceTests.cs
File metadata and controls
83 lines (77 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.TestFramework;
using Azure.ResourceManager.OperationalInsights;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.SecurityInsights.Models;
using Azure.ResourceManager.SecurityInsights.Tests.Helpers;
using NUnit.Framework;
namespace Azure.ResourceManager.SecurityInsights.Tests.TestCase
{
public class BookmarkResourceTests : SecurityInsightsManagementTestBase
{
public BookmarkResourceTests(bool isAsync)
: base(isAsync)//, RecordedTestMode.Record)
{
}
private async Task<ResourceGroupResource> GetResourceGroupAsync()
{
var resourceGroup = await CreateResourceGroupAsync();
return resourceGroup;
}
#region Workspace
private OperationalInsightsWorkspaceCollection GetWorkspaceCollectionAsync(ResourceGroupResource resourceGroup)
{
return resourceGroup.GetOperationalInsightsWorkspaces();
}
private async Task<OperationalInsightsWorkspaceResource> GetWorkspaceResourceAsync(ResourceGroupResource resourceGroup)
{
var workspaceCollection = GetWorkspaceCollectionAsync(resourceGroup);
var workspaceName1 = groupName + "-ws";
var workspaceInput = GetWorkspaceData();
var lrow = await workspaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName1, workspaceInput);
OperationalInsightsWorkspaceResource workspace = lrow.Value;
return workspace;
}
#endregion
#region Onboard
private async Task<SecurityInsightsSentinelOnboardingStateResource> GetSentinelOnboardingStateResourceAsync(OperationalInsightsWorkspaceSecurityInsightsResource operationalInsights)
{
var onboardCollection = operationalInsights.GetSecurityInsightsSentinelOnboardingStates();
var onboardName = "default";
var onboardInput = ResourceDataHelpers.GetSentinelOnboardingStateData();
var lroo = await onboardCollection.CreateOrUpdateAsync(WaitUntil.Completed, onboardName, onboardInput);
SecurityInsightsSentinelOnboardingStateResource onboard1 = lroo.Value;
return onboard1;
}
#endregion
private async Task<SecurityInsightsBookmarkResource> CreateBookmarkAsync(OperationalInsightsWorkspaceSecurityInsightsResource operationalInsights, string bookmarkName)
{
var collection = operationalInsights.GetSecurityInsightsBookmarks();
var input = ResourceDataHelpers.GetBookmarkData();
var lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bookmarkName, input);
return lro.Value;
}
[TestCase]
public async Task BookmarkResourceApiTests()
{
//0.prepare
var resourceGroup = await GetResourceGroupAsync();
var workspaceName = groupName + "-ws";
var ResourceID = CreateResourceIdentifier("db1ab6f0-4769-4b27-930e-01e2ef9c123c", groupName, workspaceName);
var operationalInsights = new OperationalInsightsWorkspaceSecurityInsightsResource(Client, ResourceID);
var workspace = await GetWorkspaceResourceAsync(resourceGroup);
var sOS = await GetSentinelOnboardingStateResourceAsync(operationalInsights);
//1.Get
var bookmarkName = "6a8d6ea6-04d5-49d7-8169-ffca8b0ced59";
var bookmark1 = await CreateBookmarkAsync(operationalInsights, bookmarkName);
SecurityInsightsBookmarkResource bookmark2 = await bookmark1.GetAsync();
ResourceDataHelpers.AssertBookmarkData(bookmark1.Data, bookmark2.Data);
//2.Delete
await bookmark1.DeleteAsync(WaitUntil.Completed);
}
}
}