mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Use response models in Api integration tests (#2592)
This commit is contained in:
@ -6,7 +6,9 @@ namespace Bit.Api.SecretManagerFeatures.Models.Response;
|
||||
|
||||
public class AccessTokenCreationResponseModel : ResponseModel
|
||||
{
|
||||
public AccessTokenCreationResponseModel(ApiKey apiKey, string obj = "accessTokenCreation") : base(obj)
|
||||
private const string _objectName = "accessTokenCreation";
|
||||
|
||||
public AccessTokenCreationResponseModel(ApiKey apiKey) : base(_objectName)
|
||||
{
|
||||
Id = apiKey.Id;
|
||||
Name = apiKey.Name;
|
||||
@ -16,10 +18,14 @@ public class AccessTokenCreationResponseModel : ResponseModel
|
||||
RevisionDate = apiKey.RevisionDate;
|
||||
}
|
||||
|
||||
public Guid Id { get; }
|
||||
public string Name { get; }
|
||||
public string ClientSecret { get; }
|
||||
public DateTime? ExpireAt { get; }
|
||||
public DateTime CreationDate { get; }
|
||||
public DateTime RevisionDate { get; }
|
||||
public AccessTokenCreationResponseModel() : base(_objectName)
|
||||
{
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
public DateTime? ExpireAt { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ namespace Bit.Api.SecretManagerFeatures.Models.Response;
|
||||
|
||||
public class BulkDeleteResponseModel : ResponseModel
|
||||
{
|
||||
public BulkDeleteResponseModel(Guid id, string error, string obj = "BulkDeleteResponseModel") : base(obj)
|
||||
private const string _objectName = "BulkDeleteResponseModel";
|
||||
|
||||
public BulkDeleteResponseModel(Guid id, string error) : base(_objectName)
|
||||
{
|
||||
Id = id;
|
||||
|
||||
@ -19,6 +21,10 @@ public class BulkDeleteResponseModel : ResponseModel
|
||||
}
|
||||
}
|
||||
|
||||
public BulkDeleteResponseModel() : base(_objectName)
|
||||
{
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string? Error { get; set; }
|
||||
|
@ -5,8 +5,10 @@ namespace Bit.Api.SecretManagerFeatures.Models.Response;
|
||||
|
||||
public class ProjectResponseModel : ResponseModel
|
||||
{
|
||||
public ProjectResponseModel(Project project, string obj = "project")
|
||||
: base(obj)
|
||||
private const string _objectName = "project";
|
||||
|
||||
public ProjectResponseModel(Project project)
|
||||
: base(_objectName)
|
||||
{
|
||||
if (project == null)
|
||||
{
|
||||
@ -20,6 +22,10 @@ public class ProjectResponseModel : ResponseModel
|
||||
RevisionDate = project.RevisionDate;
|
||||
}
|
||||
|
||||
public ProjectResponseModel() : base(_objectName)
|
||||
{
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string OrganizationId { get; set; }
|
||||
|
@ -5,8 +5,9 @@ namespace Bit.Api.SecretManagerFeatures.Models.Response;
|
||||
|
||||
public class SecretResponseModel : ResponseModel
|
||||
{
|
||||
public SecretResponseModel(Secret secret, string obj = "secret")
|
||||
: base(obj)
|
||||
private const string _objectName = "secret";
|
||||
|
||||
public SecretResponseModel(Secret secret) : base(_objectName)
|
||||
{
|
||||
if (secret == null)
|
||||
{
|
||||
@ -23,6 +24,10 @@ public class SecretResponseModel : ResponseModel
|
||||
Projects = secret.Projects?.Select(p => new InnerProject(p));
|
||||
}
|
||||
|
||||
public SecretResponseModel() : base(_objectName)
|
||||
{
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string OrganizationId { get; set; }
|
||||
@ -47,6 +52,10 @@ public class SecretResponseModel : ResponseModel
|
||||
Name = project.Name;
|
||||
}
|
||||
|
||||
public InnerProject()
|
||||
{
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
@ -5,12 +5,18 @@ namespace Bit.Api.SecretManagerFeatures.Models.Response;
|
||||
|
||||
public class SecretWithProjectsListResponseModel : ResponseModel
|
||||
{
|
||||
public SecretWithProjectsListResponseModel(IEnumerable<Secret> secrets, string obj = "SecretsWithProjectsList") : base(obj)
|
||||
private const string _objectName = "SecretsWithProjectsList";
|
||||
|
||||
public SecretWithProjectsListResponseModel(IEnumerable<Secret> secrets) : base(_objectName)
|
||||
{
|
||||
Secrets = secrets.Select(s => new InnerSecret(s));
|
||||
Projects = secrets.SelectMany(s => s.Projects).DistinctBy(p => p.Id).Select(p => new InnerProject(p));
|
||||
}
|
||||
|
||||
public SecretWithProjectsListResponseModel() : base(_objectName)
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<InnerSecret> Secrets { get; set; }
|
||||
public IEnumerable<InnerProject> Projects { get; set; }
|
||||
|
||||
@ -22,6 +28,10 @@ public class SecretWithProjectsListResponseModel : ResponseModel
|
||||
Name = project.Name;
|
||||
}
|
||||
|
||||
public InnerProject()
|
||||
{
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
@ -38,6 +48,10 @@ public class SecretWithProjectsListResponseModel : ResponseModel
|
||||
Projects = secret.Projects?.Select(p => new InnerProject(p));
|
||||
}
|
||||
|
||||
public InnerSecret()
|
||||
{
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string OrganizationId { get; set; }
|
||||
|
@ -5,8 +5,9 @@ namespace Bit.Api.SecretManagerFeatures.Models.Response;
|
||||
|
||||
public class ServiceAccountResponseModel : ResponseModel
|
||||
{
|
||||
public ServiceAccountResponseModel(ServiceAccount serviceAccount, string obj = "serviceAccount")
|
||||
: base(obj)
|
||||
private const string _objectName = "serviceAccount";
|
||||
|
||||
public ServiceAccountResponseModel(ServiceAccount serviceAccount) : base(_objectName)
|
||||
{
|
||||
if (serviceAccount == null)
|
||||
{
|
||||
@ -20,6 +21,10 @@ public class ServiceAccountResponseModel : ResponseModel
|
||||
RevisionDate = serviceAccount.RevisionDate;
|
||||
}
|
||||
|
||||
public ServiceAccountResponseModel() : base(_objectName)
|
||||
{
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string OrganizationId { get; set; }
|
||||
|
Reference in New Issue
Block a user