| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.ComponentModel; |
| | 6 | |
|
| | 7 | | namespace Azure.Security.KeyVault.Secrets |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Model factory that enables mocking for the Key Vault Secrets library. |
| | 11 | | /// </summary> |
| | 12 | | public static class SecretModelFactory |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Initializes a new instance of the <see cref="Secrets.SecretProperties"/> for mocking purposes. |
| | 16 | | /// </summary> |
| | 17 | | /// <param name="id">Sets the <see cref="Secrets.SecretProperties.Id"/> property.</param> |
| | 18 | | /// <param name="vaultUri">Sets the <see cref="Secrets.SecretProperties.VaultUri"/> property.</param> |
| | 19 | | /// <param name="name">Sets the <see cref="Secrets.SecretProperties.Name"/> property.</param> |
| | 20 | | /// <param name="version">Sets the <see cref="Secrets.SecretProperties.Version"/> property.</param> |
| | 21 | | /// <param name="managed">Sets the <see cref="Secrets.SecretProperties.Managed"/> property.</param> |
| | 22 | | /// <param name="keyId">Sets the <see cref="Secrets.SecretProperties.KeyId"/> property.</param> |
| | 23 | | /// <param name="createdOn">Sets the <see cref="Secrets.SecretProperties.CreatedOn"/> property.</param> |
| | 24 | | /// <param name="updatedOn">Sets the <see cref="Secrets.SecretProperties.UpdatedOn"/> property.</param> |
| | 25 | | /// <param name="recoveryLevel">Sets the <see cref="Secrets.SecretProperties.RecoveryLevel"/> property.</param> |
| | 26 | | /// <returns>A new instance of the <see cref="Secrets.SecretProperties"/> for mocking purposes.</returns> |
| | 27 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 28 | | public static SecretProperties SecretProperties( |
| | 29 | | Uri id, |
| | 30 | | Uri vaultUri, |
| | 31 | | string name, |
| | 32 | | string version, |
| | 33 | | bool managed, |
| | 34 | | Uri keyId, |
| | 35 | | DateTimeOffset? createdOn, |
| | 36 | | DateTimeOffset? updatedOn, |
| 0 | 37 | | string recoveryLevel) => SecretProperties( |
| 0 | 38 | | id, |
| 0 | 39 | | vaultUri, |
| 0 | 40 | | name, |
| 0 | 41 | | version, |
| 0 | 42 | | managed, |
| 0 | 43 | | keyId, |
| 0 | 44 | | createdOn, |
| 0 | 45 | | updatedOn, |
| 0 | 46 | | recoveryLevel, |
| 0 | 47 | | default); |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Initializes a new instance of the <see cref="Secrets.SecretProperties"/> for mocking purposes. |
| | 51 | | /// </summary> |
| | 52 | | /// <param name="id">Sets the <see cref="Secrets.SecretProperties.Id"/> property.</param> |
| | 53 | | /// <param name="vaultUri">Sets the <see cref="Secrets.SecretProperties.VaultUri"/> property.</param> |
| | 54 | | /// <param name="name">Sets the <see cref="Secrets.SecretProperties.Name"/> property.</param> |
| | 55 | | /// <param name="version">Sets the <see cref="Secrets.SecretProperties.Version"/> property.</param> |
| | 56 | | /// <param name="managed">Sets the <see cref="Secrets.SecretProperties.Managed"/> property.</param> |
| | 57 | | /// <param name="keyId">Sets the <see cref="Secrets.SecretProperties.KeyId"/> property.</param> |
| | 58 | | /// <param name="createdOn">Sets the <see cref="Secrets.SecretProperties.CreatedOn"/> property.</param> |
| | 59 | | /// <param name="updatedOn">Sets the <see cref="Secrets.SecretProperties.UpdatedOn"/> property.</param> |
| | 60 | | /// <param name="recoveryLevel">Sets the <see cref="Secrets.SecretProperties.RecoveryLevel"/> property.</param> |
| | 61 | | /// <param name="recoverableDays">Sets the <see cref="Secrets.SecretProperties.RecoverableDays"/> property.</par |
| | 62 | | /// <returns>A new instance of the <see cref="Secrets.SecretProperties"/> for mocking purposes.</returns> |
| | 63 | | public static SecretProperties SecretProperties( |
| | 64 | | Uri id = default, |
| | 65 | | Uri vaultUri = default, |
| | 66 | | string name = default, |
| | 67 | | string version = default, |
| | 68 | | bool managed = default, |
| | 69 | | Uri keyId = default, |
| | 70 | | DateTimeOffset? createdOn = default, |
| | 71 | | DateTimeOffset? updatedOn = default, |
| | 72 | | string recoveryLevel = default, |
| | 73 | | int? recoverableDays = default) |
| | 74 | | { |
| 0 | 75 | | return new SecretProperties |
| 0 | 76 | | { |
| 0 | 77 | | Id = id, |
| 0 | 78 | | VaultUri = vaultUri, |
| 0 | 79 | | Name = name, |
| 0 | 80 | | Version = version, |
| 0 | 81 | | Managed = managed, |
| 0 | 82 | | KeyId = keyId, |
| 0 | 83 | | CreatedOn = createdOn, |
| 0 | 84 | | UpdatedOn = updatedOn, |
| 0 | 85 | | RecoveryLevel = recoveryLevel, |
| 0 | 86 | | RecoverableDays = recoverableDays, |
| 0 | 87 | | }; |
| | 88 | | } |
| | 89 | |
|
| | 90 | | /// <summary> |
| | 91 | | /// Initializes a new instance of the <see cref="Secrets.KeyVaultSecret"/> for mocking purposes. |
| | 92 | | /// </summary> |
| | 93 | | /// <param name="properties">Sets the <see cref="Secrets.KeyVaultSecret.Properties"/> property, which provides t |
| | 94 | | /// <param name="value">Sets the <see cref="Secrets.KeyVaultSecret.Value"/> property.</param> |
| | 95 | | /// <returns>A new instance of the <see cref="Secrets.KeyVaultSecret"/> for mocking purposes.</returns> |
| 0 | 96 | | public static KeyVaultSecret KeyVaultSecret(SecretProperties properties, string value = default) => new KeyVault |
| 0 | 97 | | { |
| 0 | 98 | | Value = value, |
| 0 | 99 | | }; |
| | 100 | |
|
| | 101 | | /// <summary> |
| | 102 | | /// Initializes a new instance of the <see cref="Secrets.DeletedSecret"/> for mocking purposes. |
| | 103 | | /// </summary> |
| | 104 | | /// <param name="properties">Sets the <see cref="Secrets.KeyVaultSecret.Properties"/> property, which provides t |
| | 105 | | /// <param name="value">Sets the <see cref="Secrets.KeyVaultSecret.Value"/> property.</param> |
| | 106 | | /// <param name="recoveryId">Sets the <see cref="Secrets.DeletedSecret.RecoveryId"/> property.</param> |
| | 107 | | /// <param name="deletedOn">Sets the <see cref="Secrets.DeletedSecret.DeletedOn"/> property.</param> |
| | 108 | | /// <param name="scheduledPurgeDate">Sets the <see cref="Secrets.DeletedSecret.ScheduledPurgeDate"/> property.</ |
| | 109 | | /// <returns>A new instance of the <see cref="Secrets.DeletedSecret"/> for mocking purposes.</returns> |
| 0 | 110 | | public static DeletedSecret DeletedSecret(SecretProperties properties, string value = default, Uri recoveryId = |
| 0 | 111 | | { |
| 0 | 112 | | Value = value, |
| 0 | 113 | | RecoveryId = recoveryId, |
| 0 | 114 | | DeletedOn = deletedOn, |
| 0 | 115 | | ScheduledPurgeDate = scheduledPurgeDate, |
| 0 | 116 | | }; |
| | 117 | | } |
| | 118 | | } |