Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
62f68ac
feat(secretmanager): Adding labels and annotations sample
khilan-crest Jan 22, 2026
0b20481
feat(secretmanager): Adding filter and cmek samples
khilan-crest Jan 22, 2026
dee8bc1
feat(secretmanager): Adding secret version filter samples
khilan-crest Jan 22, 2026
d21d2a7
feat(secretmanager): Adding secrets expiration samples
khilan-crest Jan 27, 2026
5832e34
feat(secretmanager): Update labels annotations samples
khilan-crest Jan 27, 2026
7b77ac3
feat(secretmanager): Update cmek filter samples
khilan-crest Jan 27, 2026
e4fe6a0
Merge branch 'cs_labels_annotation_samples' of https://github.com/khi…
khilan-crest Jan 27, 2026
43f47dd
Merge branch 'cs_filter_cmek_samples' of https://github.com/khilan-cr…
khilan-crest Jan 27, 2026
922ff50
feat(secretmanager): Update expiration samples
khilan-crest Jan 27, 2026
cdd5217
feat(secretmanager): Updating fixture
khilan-crest Jan 28, 2026
3933710
Merge branch 'cs_filter_cmek_samples' of https://github.com/khilan-cr…
khilan-crest Jan 28, 2026
2b756f1
feat(secretmanager): Updating fixture
khilan-crest Jan 28, 2026
4641d03
feat(secretmanager): Reformat code
khilan-crest Jan 28, 2026
cdbc3c2
Merge branch 'cs_labels_annotation_samples' of https://github.com/khi…
khilan-crest Jan 28, 2026
34e7a7a
feat(secretmanager): Reformat code
khilan-crest Jan 28, 2026
32295a4
Merge branch 'cs_filter_cmek_samples' of https://github.com/khilan-cr…
khilan-crest Jan 28, 2026
5a4e75a
feat(secretmanager): Reformat code
khilan-crest Jan 28, 2026
2f0bfb5
feat(secretmanager): Reformat code
khilan-crest Jan 28, 2026
7dea915
Merge branch 'cs_labels_annotation_samples' of https://github.com/khi…
khilan-crest Jan 28, 2026
a24afb7
Merge branch 'cs_filter_cmek_samples' of https://github.com/khilan-cr…
khilan-crest Jan 28, 2026
2c1de99
feat(secretmanager): Reformat code
khilan-crest Jan 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.SecretManager.V1;
using System;
using System.IO;
using Xunit;

[Collection(nameof(RegionalSecretManagerFixture))]
public class CreateRegionalSecretWithExpireTimeTests
{
private readonly RegionalSecretManagerFixture _fixture;
private readonly CreateRegionalSecretWithExpireTimeSample _sample;

public CreateRegionalSecretWithExpireTimeTests(RegionalSecretManagerFixture fixture)
{
_fixture = fixture;
_sample = new CreateRegionalSecretWithExpireTimeSample();
}

[Fact]
public void CreatesRegionalSecretWithExpireTime()
{
// Get the SecretName from the set ProjectId & LocationId.
SecretName secretName = SecretName.FromProjectLocationSecret(
_fixture.ProjectId, _fixture.LocationId, _fixture.RandomId());
try
{
// Run the code sample.
Secret result = _sample.CreateRegionalSecretWithExpireTime(
projectId: secretName.ProjectId,
secretId: secretName.SecretId,
locationId: secretName.LocationId);

Assert.NotNull(result.ExpireTime);
}
finally
{
// Clean the created secret.
_fixture.DeleteSecret(secretName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.SecretManager.V1;
using Google.Protobuf.WellKnownTypes;
using System;
using System.IO;
using Xunit;

[Collection(nameof(SecretManagerFixture))]
public class CreateSecretWithExpirationTests
{
private readonly SecretManagerFixture _fixture;
private readonly CreateSecretWithExpirationSample _sample;

public CreateSecretWithExpirationTests(SecretManagerFixture fixture)
{
_fixture = fixture;
_sample = new CreateSecretWithExpirationSample();
}

[Fact]
public void CreatesSecretWithExpiration()
{
// Get the SecretName to create Secret.
SecretName secretName = new SecretName(_fixture.ProjectId, _fixture.RandomId());
try
{
// Create the secret with expiration.
Secret result = _sample.CreateSecretWithExpiration(
projectId: secretName.ProjectId, secretId: secretName.SecretId);

Assert.NotNull(result.ExpireTime);
}
finally
{
// Clean the created secret.
_fixture.DeleteSecret(secretName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.SecretManager.V1;
using System;
using System.IO;
using Xunit;

[Collection(nameof(RegionalSecretManagerFixture))]
public class DeleteRegionalSecretAnnotationTests
{
private readonly RegionalSecretManagerFixture _fixture;
private readonly DeleteRegionalSecretAnnotationSample _sample;

public DeleteRegionalSecretAnnotationTests(RegionalSecretManagerFixture fixture)
{
_fixture = fixture;
_sample = new DeleteRegionalSecretAnnotationSample();
}

[Fact]
public void DeleteRegionalSecretAnnotation()
{
// Create a secret with annotations
Secret secret = _fixture.CreateSecret(_fixture.RandomId());
SecretName secretName = secret.SecretName;
try
{
// Get a key from the existing annotations
string annotationKey = _fixture.AnnotationKey;

// Verify the secret has annotations
Assert.NotEmpty(secret.Annotations);
Assert.True(secret.Annotations.ContainsKey(annotationKey));

// Run the sample code to delete the annotation
Secret result = _sample.DeleteRegionalSecretAnnotation(
projectId: secretName.ProjectId,
locationId: secretName.LocationId,
secretId: secretName.SecretId);

Assert.Empty(result.Annotations);
}
finally
{
// Clean the created secret.
_fixture.DeleteSecret(secretName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.SecretManager.V1;
using Google.Protobuf.WellKnownTypes;
using System;
using System.IO;
using Xunit;

[Collection(nameof(RegionalSecretManagerFixture))]
public class DeleteRegionalSecretExpirationTests
{
private readonly RegionalSecretManagerFixture _fixture;
private readonly DeleteRegionalSecretExpirationSample _deleteSample;

public DeleteRegionalSecretExpirationTests(RegionalSecretManagerFixture fixture)
{
_fixture = fixture;
_deleteSample = new DeleteRegionalSecretExpirationSample();
}

[Fact]
public void DeletesRegionalSecretExpiration()
{
Secret initialSecret = _fixture.CreateSecretWithExpireTime();
try
{
// Delete the expiration time
Secret result = _deleteSample.DeleteRegionalSecretExpiration(
projectId: initialSecret.SecretName.ProjectId,
secretId: initialSecret.SecretName.SecretId,
locationId: initialSecret.SecretName.LocationId);

Assert.Null(result.ExpireTime);
}
finally
{
// Clean the created secret
_fixture.DeleteSecret(initialSecret.SecretName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.SecretManager.V1;
using System;
using System.IO;
using Xunit;

[Collection(nameof(RegionalSecretManagerFixture))]
public class DeleteRegionalSecretLabelTests
{
private readonly RegionalSecretManagerFixture _fixture;
private readonly DeleteRegionalSecretLabelSample _sample;

public DeleteRegionalSecretLabelTests(RegionalSecretManagerFixture fixture)
{
_fixture = fixture;
_sample = new DeleteRegionalSecretLabelSample();
}

[Fact]
public void DeleteRegionalSecretLabel()
{
Secret secret = _fixture.CreateSecret(_fixture.RandomId());
SecretName secretName = secret.SecretName;
try
{
// Verify the secret has labels
Assert.NotEmpty(secret.Labels);

// Run the sample code to delete all labels
Secret result = _sample.DeleteRegionalSecretLabel(

projectId: secretName.ProjectId,
locationId: secretName.LocationId,
secretId: secretName.SecretId);

Assert.Empty(result.Labels);
}
finally
{
// Clean the created secret.
_fixture.DeleteSecret(secretName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Google.Cloud.SecretManager.V1;
using System;
using System.IO;
using Xunit;

[Collection(nameof(SecretManagerFixture))]
public class DeleteSecretAnnotationTests
{
private readonly SecretManagerFixture _fixture;
private readonly DeleteSecretAnnotationSample _sample;

public DeleteSecretAnnotationTests(SecretManagerFixture fixture)
{
_fixture = fixture;
_sample = new DeleteSecretAnnotationSample();
}

[Fact]
public void DeleteSecretAnnotation()
{
// Create the secret.
Secret secret = _fixture.CreateSecret(_fixture.RandomId());
// Get the secretName from the created secret.
SecretName secretName = secret.SecretName;
try
{
Assert.NotEmpty(secret.Annotations);
// Call the code sample function to delete the annotations
Secret result = _sample.DeleteSecretAnnotation(
projectId: secretName.ProjectId, secretId: secretName.SecretId);

// Assert that the label is deleted.
Assert.Empty(result.Annotations);
}
finally
{
// Clean the created secret.
_fixture.DeleteSecret(secretName);
}
}
}
Loading