diff --git a/backend/src/Designer/Controllers/KubernetesDeploymentsController.cs b/backend/src/Designer/Controllers/KubernetesDeploymentsController.cs
deleted file mode 100644
index ca1330c74ae..00000000000
--- a/backend/src/Designer/Controllers/KubernetesDeploymentsController.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-using Altinn.Studio.Designer.Services.Interfaces;
-using Altinn.Studio.Designer.TypedHttpClients.KubernetesWrapper;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Altinn.Studio.Designer.Controllers
-{
- ///
- /// Controller for getting kubernetes deployments
- ///
- [ApiController]
- [Authorize]
- [AutoValidateAntiforgeryToken]
- [Route("/designer/api/{org}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/kubernetesDeployments")]
- public class KubernetesDeploymentsController : ControllerBase
- {
- private readonly IKubernetesDeploymentsService _kubernetesDeploymentsService;
-
- ///
- /// Constructor
- ///
- /// IKubernetesDeploymentsService
- public KubernetesDeploymentsController(IKubernetesDeploymentsService kubernetesDeploymentsService)
- {
- _kubernetesDeploymentsService = kubernetesDeploymentsService;
- }
-
- ///
- /// Gets kubernetes deployments
- ///
- /// Organisation
- /// Application name
- /// List of kubernetes deployments
- [HttpGet]
- [ApiConventionMethod(typeof(DefaultApiConventions), nameof(DefaultApiConventions.Get))]
- public async Task> Get(string org, string app)
- {
- return await _kubernetesDeploymentsService.GetAsync(org, app);
- }
- }
-}
diff --git a/backend/src/Designer/Controllers/LanguagesController.cs b/backend/src/Designer/Controllers/LanguagesController.cs
deleted file mode 100644
index 1f99ec8b17b..00000000000
--- a/backend/src/Designer/Controllers/LanguagesController.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections.Generic;
-
-using Altinn.Studio.Designer.Helpers;
-using Altinn.Studio.Designer.Services.Interfaces;
-
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Altinn.Studio.Designer.Controllers
-{
- ///
- /// Controller containing actions related to languages
- ///
- [Authorize]
- [AutoValidateAntiforgeryToken]
- [Route("designer/api/{org}/{repo:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/languages")]
- public class LanguagesController : ControllerBase
- {
- private readonly ILanguagesService _languagesService;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The languages service.
- public LanguagesController(ILanguagesService languagesService)
- {
- _languagesService = languagesService;
- }
-
- ///
- /// Endpoint for getting the available languages in the application.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Application identifier which is unique within an organisation.
- /// List of languages as JSON
- [HttpGet]
- [Produces("application/json")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult> GetLanguages(string org, string repo)
- {
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
-
- List languages = new List(_languagesService.GetLanguages(org, repo, developer));
-
- return Ok(languages);
- }
- }
-}
diff --git a/backend/src/Designer/Controllers/ProcessModelingController.cs b/backend/src/Designer/Controllers/ProcessModelingController.cs
index df5e88e4e8f..c0ce99c2f23 100644
--- a/backend/src/Designer/Controllers/ProcessModelingController.cs
+++ b/backend/src/Designer/Controllers/ProcessModelingController.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Net.Mime;
using System.Text.Json;
@@ -14,7 +13,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using NuGet.Versioning;
namespace Altinn.Studio.Designer.Controllers
{
@@ -102,27 +100,6 @@ await _mediator.Publish(new ProcessDataTypesChangedEvent
return Accepted();
}
- [HttpGet("templates/{appVersion}")]
- public IEnumerable GetTemplates(string org, string repo, SemanticVersion appVersion)
- {
- Guard.AssertArgumentNotNull(appVersion, nameof(appVersion));
- return _processModelingService.GetProcessDefinitionTemplates(appVersion);
- }
-
- [HttpPut("templates/{appVersion}/{templateName}")]
- public async Task SaveProcessDefinitionFromTemplate(string org, string repo,
- SemanticVersion appVersion, string templateName, CancellationToken cancellationToken)
- {
- Guard.AssertArgumentNotNull(appVersion, nameof(appVersion));
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
- var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, repo, developer);
- await _processModelingService.SaveProcessDefinitionFromTemplateAsync(editingContext, templateName,
- appVersion, cancellationToken);
-
- Stream processDefinitionStream = _processModelingService.GetProcessDefinitionStream(editingContext);
- return new FileStreamResult(processDefinitionStream, MediaTypeNames.Text.Plain);
- }
-
[HttpPost("data-type/{dataTypeId}")]
public async Task AddDataTypeToApplicationMetadata(string org, string repo, [FromRoute] string dataTypeId, [FromQuery] string taskId, CancellationToken cancellationToken)
{
diff --git a/backend/src/Designer/Controllers/RepositoryController.cs b/backend/src/Designer/Controllers/RepositoryController.cs
index 093394037f8..2219fe9c576 100644
--- a/backend/src/Designer/Controllers/RepositoryController.cs
+++ b/backend/src/Designer/Controllers/RepositoryController.cs
@@ -343,32 +343,6 @@ public async Task Push(string org, string repository)
return pushSuccess ? Ok() : StatusCode(StatusCodes.Status500InternalServerError);
}
- ///
- /// Fetches the repository log
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The repo name
- /// List of commits
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/log")]
- public List Log(string org, string repository)
- {
- return _sourceControl.Log(org, repository);
- }
-
- ///
- /// Fetches the initial commit
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The repo name
- /// The initial commit
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/initial-commit")]
- public Commit GetInitialCommit(string org, string repository)
- {
- return _sourceControl.GetInitialCommit(org, repository);
- }
-
///
/// Gets the latest commit from current user
///
@@ -382,82 +356,6 @@ public Commit GetLatestCommitFromCurrentUser(string org, string repository)
return _sourceControl.GetLatestCommitForCurrentUser(org, repository);
}
- ///
- /// List all branches for a repository
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The repository
- /// List of repos
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/branches")]
- public async Task> Branches(string org, string repository)
- => await _giteaApi.GetBranches(org, repository);
-
- ///
- /// Returns information about a given branch
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of repository
- /// Name of branch
- /// The branch info
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/branches/branch")]
- public async Task Branch(string org, string repository, [FromQuery] string branch)
- => await _giteaApi.GetBranch(org, repository, branch);
-
- ///
- /// Discards all local changes for the logged in user and the local repository is updated with latest remote commit (origin/master)
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of repository
- /// Http response message as ok if reset operation is successful
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/discard")]
- public ActionResult DiscardLocalChanges(string org, string repository)
- {
- try
- {
- if (string.IsNullOrEmpty(org) || string.IsNullOrEmpty(repository))
- {
- return ValidationProblem("One or all of the input parameters are null");
- }
-
- _sourceControl.ResetCommit(org, repository);
- return Ok();
- }
- catch (Exception)
- {
- return StatusCode(StatusCodes.Status500InternalServerError);
- }
- }
-
- ///
- /// Discards local changes to a specific file and the files is updated with latest remote commit (origin/master)
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of repository
- /// the name of the file
- /// Http response message as ok if checkout operation is successful
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/discard/{fileName}")]
- public ActionResult DiscardLocalChangesForSpecificFile(string org, string repository, string fileName)
- {
- try
- {
- if (string.IsNullOrEmpty(org) || string.IsNullOrEmpty(repository) || string.IsNullOrEmpty(fileName))
- {
- return ValidationProblem("One or all of the input parameters are null");
- }
-
- _sourceControl.CheckoutLatestCommitForSpecificFile(org, repository, fileName);
- return Ok();
- }
- catch (Exception)
- {
- return StatusCode(StatusCodes.Status500InternalServerError);
- }
- }
-
///
/// Stages a specific file changed in working repository.
///
@@ -485,46 +383,6 @@ public ActionResult StageChange(string org, string repository, string fileName)
}
}
- ///
- /// Clones the remote repository
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of repository
- /// The result of the cloning
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/clone")]
- public Task CloneRemoteRepository(string org, string repository)
- {
- return _sourceControl.CloneRemoteRepository(org, repository);
- }
-
- ///
- /// Halts the merge operation and keeps local changes
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of the repository
- /// Http response message as ok if abort merge operation is successful
- [HttpGet]
- [Route("repo/{org}/{repository:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/abort-merge")]
- public ActionResult AbortMerge(string org, string repository)
- {
- try
- {
- if (string.IsNullOrEmpty(org) || string.IsNullOrEmpty(repository))
- {
- return ValidationProblem("One or all of the input parameters are null");
- }
-
- _sourceControl.AbortMerge(org, repository);
-
- return Ok();
- }
- catch (Exception)
- {
- return StatusCode(StatusCodes.Status500InternalServerError);
- }
- }
-
///
/// Gets the repository content
///
diff --git a/backend/src/Designer/Controllers/TextKeysController.cs b/backend/src/Designer/Controllers/TextKeysController.cs
deleted file mode 100644
index 843ac619edb..00000000000
--- a/backend/src/Designer/Controllers/TextKeysController.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Altinn.Studio.Designer.Helpers;
-using Altinn.Studio.Designer.Services.Interfaces;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Altinn.Studio.Designer.Controllers
-{
- ///
- /// Controller containing actions related to text keys
- ///
- [Authorize]
- [AutoValidateAntiforgeryToken]
- [Route("designer/api/{org}/{repo:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/text-keys")]
- public class TextKeysController : ControllerBase
- {
- private readonly ILanguagesService _languagesService;
- private readonly ITextsService _textsService;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The languages service.
- /// The texts service.
- public TextKeysController(ILanguagesService languagesService, ITextsService textsService)
- {
- _languagesService = languagesService;
- _textsService = textsService;
- }
-
- ///
- /// Endpoint for getting a list of all keys.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Application identifier which is unique within an organisation.
- /// List of keys
- [HttpGet]
- [Produces("application/json")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- public async Task>> Get(string org, string repo)
- {
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
-
- try
- {
- IList languages = _languagesService.GetLanguages(org, repo, developer);
- List keys = await _textsService.GetKeys(org, repo, developer, languages);
- return Ok(keys);
- }
- catch (JsonException)
- {
- return new ObjectResult(new
- {
- errorMessage =
- "The format of one or more texts files that you tried to access might be invalid."
- })
- { StatusCode = 500 };
- }
- catch (FileNotFoundException)
- {
- return NotFound("The texts files needed to get the keys could not be found or does not exist.");
- }
- }
-
- ///
- /// Endpoint for changing or deleting a single key in the texts files for all languages.
- /// If deleting, an empty string is sent as "newKey". Key and belonging value is
- /// deleted from all texts files.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Application identifier which is unique within an organisation.
- /// Old key to be replaced.
- /// New key to replace the old.
- /// KeyValuePair of new key and belonging text.
- [HttpPut]
- [Produces("application/json")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- public async Task>> Put(string org, string repo, [FromQuery] string oldKey, [FromQuery] string newKey)
- {
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
- IList languages = _languagesService.GetLanguages(org, repo, developer);
-
- try
- {
- string response = await _textsService.UpdateKey(org, repo, developer, languages, oldKey, newKey);
- return Ok(response);
- }
- catch (JsonException)
- {
- return new ObjectResult(new { errorMessage = "The format of one or more texts files that you tried to access might be invalid." }) { StatusCode = 500 };
- }
- catch (FileNotFoundException)
- {
- return NotFound("The texts files needed to update key could not be found or does not exist.");
- }
- catch (ArgumentException)
- {
- string errorMessage = !string.IsNullOrEmpty(newKey) && !string.IsNullOrEmpty(oldKey)
- ? $"It looks like the key, {newKey}, that you tried to insert already exists in one or more texts files."
- : "The arguments sent to this request was illegal.";
- return BadRequest(errorMessage);
- }
- catch (Exception errorMessage)
- {
- return BadRequest(errorMessage);
- }
- }
- }
-}
diff --git a/backend/src/Designer/Controllers/TextsController.cs b/backend/src/Designer/Controllers/TextsController.cs
deleted file mode 100644
index c1b55f4fe73..00000000000
--- a/backend/src/Designer/Controllers/TextsController.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Text.Json;
-using System.Threading.Tasks;
-
-using Altinn.Studio.Designer.Helpers;
-using Altinn.Studio.Designer.Services.Interfaces;
-
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Altinn.Studio.Designer.Controllers
-{
- ///
- /// Controller containing actions related to text files in the
- /// new format; *.texts.json with key:value pairs.
- ///
- ///
- /// NB: Must not be confused with TextController (singular)
- /// which interacts with the text files in the old format.
- ///
- [Authorize]
- [AutoValidateAntiforgeryToken]
- [Route("designer/api/{org}/{repo:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/texts")]
- public class TextsController : ControllerBase
- {
- private readonly ITextsService _textsService;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The texts service.
- public TextsController(ITextsService textsService)
- {
- _textsService = textsService;
- }
-
- ///
- /// Endpoint for getting the complete text file for a specific language.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Application identifier which is unique within an organisation.
- /// Language identifier specifying the text file to read.
- /// Text file
- /// If duplicates of keys are tried added the
- /// deserialization to dictionary will overwrite the first
- /// key:value pair with the last key:value pair
- [HttpGet]
- [Produces("application/json")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- [Route("language/{languageCode}")]
- public async Task>> Get(string org, string repo, [FromRoute] string languageCode)
- {
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
-
- try
- {
- Dictionary texts = await _textsService.GetTextsV2(org, repo, developer, languageCode);
- return Ok(texts);
- }
- catch (IOException)
- {
- return NotFound($"The texts file, {languageCode}.texts.json, that you are trying to find does not exist.");
- }
- catch (JsonException)
- {
- return new ObjectResult(new { errorMessage = $"The format of the file, {languageCode}.texts.json, that you tried to access might be invalid." }) { StatusCode = 500 };
- }
- }
-
- ///
- /// Endpoint for updating a text file for a specific language.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Application identifier which is unique within an organisation.
- /// Language identifier specifying the text file to read.
- /// New content from request body to be added to the text file.
- /// If duplicates of keys are tried added the
- /// deserialization to dictionary will overwrite the first
- /// key:value pair with the last key:value pair
- [HttpPut]
- [Produces("application/json")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [Route("language/{languageCode}")]
- public async Task Put(string org, string repo, string languageCode, [FromBody] Dictionary jsonTexts)
- {
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
-
- if (jsonTexts == null)
- {
- return BadRequest($"The texts file, {languageCode}.texts.json, that you are trying to add have invalid format.");
- }
-
- await _textsService.UpdateTexts(org, repo, developer, languageCode, jsonTexts);
- Dictionary savedTexts = await _textsService.GetTextsV2(org, repo, developer, languageCode);
-
- return Ok(savedTexts);
- }
-
- ///
- /// Endpoint for converting all texts files to the new flat
- /// format in a specific repository for a specific organisation.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Application identifier which is unique within an organisation.
- [HttpPut]
- [Produces("application/json")]
- [Route("convert")]
- public async Task Convert(string org, string repo)
- {
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
-
- await _textsService.ConvertV1TextsToV2(org, repo, developer);
-
- return NoContent();
- }
-
- ///
- /// Endpoint for deleting a specific language in the application.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Application identifier which is unique within an organisation.
- /// Language identifier.
- [HttpDelete]
- [Produces("application/json")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [Route("language/{languageCode}")]
- public ActionResult Delete(string org, string repo, [FromRoute] string languageCode)
- {
- string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
-
- _textsService.DeleteTexts(org, repo, developer, languageCode);
-
- return Ok($"Texts file, {languageCode}.texts.json, was successfully deleted.");
- }
- }
-}
diff --git a/backend/src/Designer/Infrastructure/GitRepository/AltinnGitRepository.cs b/backend/src/Designer/Infrastructure/GitRepository/AltinnGitRepository.cs
index 6515c1d736d..0d208ed5e3e 100644
--- a/backend/src/Designer/Infrastructure/GitRepository/AltinnGitRepository.cs
+++ b/backend/src/Designer/Infrastructure/GitRepository/AltinnGitRepository.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
@@ -115,16 +114,6 @@ public string GetSchemaName(string filePath)
return string.Empty;
}
- ///
- /// Finds all texts files regardless of location in repository.
- ///
- public IList GetLanguageFiles()
- {
- IEnumerable languageFiles = FindFiles(new string[] { TEXT_FILES_PATTERN_JSON });
-
- return languageFiles.ToList();
- }
-
///
/// Gets a representation of a file. This does not load any
/// file contents but i do ensure the file exists ang gives some easy handles to file location and url
diff --git a/backend/src/Designer/Infrastructure/ServiceRegistration.cs b/backend/src/Designer/Infrastructure/ServiceRegistration.cs
index 599a8bc1d47..1a17d20b015 100644
--- a/backend/src/Designer/Infrastructure/ServiceRegistration.cs
+++ b/backend/src/Designer/Infrastructure/ServiceRegistration.cs
@@ -65,7 +65,6 @@ public static IServiceCollection RegisterServiceImplementations(this IServiceCol
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
diff --git a/backend/src/Designer/Middleware/UserRequestSynchronization/Services/RequestSyncEvaluators/EndpointNameSyncEvaluator.cs b/backend/src/Designer/Middleware/UserRequestSynchronization/Services/RequestSyncEvaluators/EndpointNameSyncEvaluator.cs
index 36cc15d842b..1fbec7049b8 100644
--- a/backend/src/Designer/Middleware/UserRequestSynchronization/Services/RequestSyncEvaluators/EndpointNameSyncEvaluator.cs
+++ b/backend/src/Designer/Middleware/UserRequestSynchronization/Services/RequestSyncEvaluators/EndpointNameSyncEvaluator.cs
@@ -54,8 +54,7 @@ public class EndpointNameSyncEvaluator : IRequestSyncEvaluator
nameof(ProcessModelingController.AddDataTypeToApplicationMetadata),
nameof(ProcessModelingController.DeleteDataTypeFromApplicationMetadata),
nameof(ProcessModelingController.UpsertProcessDefinitionAndNotify),
- nameof(ProcessModelingController.ProcessDataTypesChangedNotify),
- nameof(ProcessModelingController.SaveProcessDefinitionFromTemplate)
+ nameof(ProcessModelingController.ProcessDataTypesChangedNotify)
)
},
{
diff --git a/backend/src/Designer/Services/Implementation/GiteaAPIWrapper/GiteaAPIWrapper.cs b/backend/src/Designer/Services/Implementation/GiteaAPIWrapper/GiteaAPIWrapper.cs
index 6af6bcef16b..9b488418a61 100644
--- a/backend/src/Designer/Services/Implementation/GiteaAPIWrapper/GiteaAPIWrapper.cs
+++ b/backend/src/Designer/Services/Implementation/GiteaAPIWrapper/GiteaAPIWrapper.cs
@@ -394,34 +394,6 @@ public async Task> GetUserOrganizations()
return null;
}
- ///
- public async Task> GetBranches(string org, string repo)
- {
- HttpResponseMessage response = await _httpClient.GetAsync($"repos/{org}/{repo}/branches");
- if (response.StatusCode == HttpStatusCode.OK)
- {
- return await response.Content.ReadAsAsync>();
- }
-
- _logger.LogError("User " + AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext) + " GetBranches response failed with statuscode " + response.StatusCode + " for " + org + " " + repo);
-
- return new List();
- }
-
- ///
- public async Task GetBranch(string org, string repository, string branch)
- {
- HttpResponseMessage response = await _httpClient.GetAsync($"repos/{org}/{repository}/branches/{branch}");
- if (response.StatusCode == HttpStatusCode.OK)
- {
- return await response.Content.ReadAsAsync();
- }
-
- _logger.LogError("User " + AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext) + " GetBranch response failed with statuscode " + response.StatusCode + " for " + org + " / " + repository + " branch: " + branch);
-
- return null;
- }
-
///
public async Task CreateBranch(string org, string repository, string branchName)
{
diff --git a/backend/src/Designer/Services/Implementation/LanguagesService.cs b/backend/src/Designer/Services/Implementation/LanguagesService.cs
deleted file mode 100644
index 3f4009b398c..00000000000
--- a/backend/src/Designer/Services/Implementation/LanguagesService.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-
-using Altinn.Studio.Designer.Services.Interfaces;
-
-namespace Altinn.Studio.Designer.Services.Implementation
-{
- ///
- /// Relevant text resource functions
- ///
- public class LanguagesService : ILanguagesService
- {
- private readonly IAltinnGitRepositoryFactory _altinnGitRepositoryFactory;
-
- ///
- /// Constructor
- ///
- /// IAltinnGitRepository
- public LanguagesService(IAltinnGitRepositoryFactory altinnGitRepositoryFactory)
- {
- _altinnGitRepositoryFactory = altinnGitRepositoryFactory;
- }
-
- ///
- public IList GetLanguages(string org, string repo, string developer)
- {
- var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
-
- List languages = new List();
-
- IList languageFiles = altinnAppGitRepository.GetLanguageFiles();
-
- foreach (string languageFile in languageFiles)
- {
- string fileName = Path.GetFileName(languageFile);
- string[] nameParts = fileName.Split('.');
- languages.Add(nameParts[0]);
- }
-
- languages.Sort();
-
- return languages;
- }
- }
-}
diff --git a/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs b/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs
index 3c01e869a16..1c380c1b8a2 100644
--- a/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs
+++ b/backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs
@@ -27,23 +27,6 @@ public ProcessModelingService(IAltinnGitRepositoryFactory altinnGitRepositoryFac
private string TemplatesFolderIdentifier(SemanticVersion version) => string.Join(".", nameof(Services), nameof(Implementation), nameof(ProcessModeling), "Templates", $"v{version.Major}");
- ///
- public IEnumerable GetProcessDefinitionTemplates(SemanticVersion version)
- {
- return EnumerateTemplateResources(version)
- .Select(
- templateName => templateName.Split(TemplatesFolderIdentifier(version)).Last().TrimStart('.'))!;
- }
-
- ///
- public async Task SaveProcessDefinitionFromTemplateAsync(AltinnRepoEditingContext altinnRepoEditingContext, string templateName, SemanticVersion version, CancellationToken cancellationToken = default)
- {
- cancellationToken.ThrowIfCancellationRequested();
- AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(altinnRepoEditingContext.Org, altinnRepoEditingContext.Repo, altinnRepoEditingContext.Developer);
- await using Stream templateStream = GetTemplateStream(version, templateName);
- await altinnAppGitRepository.SaveProcessDefinitionFileAsync(templateStream, cancellationToken);
- }
-
///
public async Task SaveProcessDefinitionAsync(AltinnRepoEditingContext altinnRepoEditingContext, Stream bpmnStream, CancellationToken cancellationToken = default)
{
diff --git a/backend/src/Designer/Services/Implementation/SourceControlLoggingDecorator.cs b/backend/src/Designer/Services/Implementation/SourceControlLoggingDecorator.cs
index aa73e0e62b3..d33c59f27d1 100644
--- a/backend/src/Designer/Services/Implementation/SourceControlLoggingDecorator.cs
+++ b/backend/src/Designer/Services/Implementation/SourceControlLoggingDecorator.cs
@@ -37,34 +37,6 @@ public SourceControlLoggingDecorator(ISourceControl decoratedService, GeneralSet
_httpContextAccessor = httpContextAccessor;
}
- ///
- public void AbortMerge(string org, string repository)
- {
- try
- {
- _decoratedService.AbortMerge(org, repository);
- }
- catch (Exception ex)
- {
- LogError(ex, "AbortMerge", org, repository);
- throw;
- }
- }
-
- ///
- public void CheckoutLatestCommitForSpecificFile(string org, string repository, string fileName)
- {
- try
- {
- _decoratedService.CheckoutLatestCommitForSpecificFile(org, repository, fileName);
- }
- catch (Exception ex)
- {
- LogError(ex, "CheckoutLatestCommitForSpecificFile", org, repository);
- throw;
- }
- }
-
///
public Task CloneRemoteRepository(string org, string repository)
{
@@ -177,20 +149,6 @@ public async Task FetchRemoteChanges(string org, string repository)
}
}
- ///
- public Commit GetInitialCommit(string org, string repository)
- {
- try
- {
- return _decoratedService.GetInitialCommit(org, repository);
- }
- catch (Exception ex)
- {
- LogError(ex, "GetInitialCommit", org, repository);
- throw;
- }
- }
-
///
public Commit GetLatestCommitForCurrentUser(string org, string repository)
{
@@ -289,20 +247,6 @@ public Task> GetChangedContent(string org, string rep
}
}
- ///
- public void ResetCommit(string org, string repository)
- {
- try
- {
- _decoratedService.ResetCommit(org, repository);
- }
- catch (Exception ex)
- {
- LogError(ex, "ResetCommit", org, repository);
- throw;
- }
- }
-
///
public void StageChange(string org, string repository, string fileName)
{
diff --git a/backend/src/Designer/Services/Implementation/SourceControlSI.cs b/backend/src/Designer/Services/Implementation/SourceControlSI.cs
index ba532203c9b..c07399402c8 100644
--- a/backend/src/Designer/Services/Implementation/SourceControlSI.cs
+++ b/backend/src/Designer/Services/Implementation/SourceControlSI.cs
@@ -376,40 +376,6 @@ public Altinn.Studio.Designer.Models.Commit GetLatestCommitForCurrentUser(string
return commits;
}
- ///
- public Designer.Models.Commit GetInitialCommit(string org, string repository)
- {
- string localServiceRepoFolder = _settings.GetServicePath(org, repository, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext));
- Designer.Models.Commit commit = null;
-
- using var repo = new LibGit2Sharp.Repository(localServiceRepoFolder);
- if (repo.Commits.Any() && repo.Commits.Last() != null)
- {
- LibGit2Sharp.Commit firstCommit = repo.Commits.Last();
- commit = new Designer.Models.Commit();
- commit.Message = firstCommit.Message;
- commit.MessageShort = firstCommit.MessageShort;
- commit.Encoding = firstCommit.Encoding;
- commit.Sha = firstCommit.Sha;
-
- commit.Author = new Designer.Models.Signature();
- commit.Author.Email = firstCommit.Author.Email;
- commit.Author.Name = firstCommit.Author.Name;
- commit.Author.When = firstCommit.Author.When;
-
- commit.Comitter = new Designer.Models.Signature();
- commit.Comitter.Name = firstCommit.Committer.Name;
- commit.Comitter.Email = firstCommit.Committer.Email;
- commit.Comitter.When = firstCommit.Committer.When;
- }
- else
- {
- _logger.LogWarning($" // SourceControlSI // GetInitialCommit // Did not find any commits in repo {localServiceRepoFolder}");
- }
-
- return commit;
- }
-
///
/// Method for storing AppToken in Developers folder. This is not the permanent solution
///
@@ -518,45 +484,6 @@ private string FindRemoteRepoLocation(string org, string repository)
return new Uri(_settings.RepositoryBaseURL).Append($"{org}/{repository}.git").ToString();
}
- ///
- /// Discards all local changes for the logged in user and the local repository is updated with latest remote commit (origin/master)
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of the repository
- public void ResetCommit(string org, string repository)
- {
- string localServiceRepoFolder = _settings.GetServicePath(org, repository, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext));
- using (LibGit2Sharp.Repository repo = new(localServiceRepoFolder))
- {
- if (repo.RetrieveStatus().IsDirty)
- {
- repo.Reset(ResetMode.Hard, "origin/master");
- repo.RemoveUntrackedFiles();
- }
- }
- }
-
- ///
- /// Discards local changes to a specific file and the file is updated with latest remote commit (origin/master)
- /// by checking out the specific file.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of the repository
- /// the name of the file
- public void CheckoutLatestCommitForSpecificFile(string org, string repository, string fileName)
- {
- string localServiceRepoFolder = _settings.GetServicePath(org, repository, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext));
- using (LibGit2Sharp.Repository repo = new(localServiceRepoFolder))
- {
- CheckoutOptions checkoutOptions = new()
- {
- CheckoutModifiers = CheckoutModifiers.Force,
- };
-
- repo.CheckoutPaths("origin/master", new[] { fileName }, checkoutOptions);
- }
- }
-
///
/// Stages a specific file changed in working repository.
///
@@ -579,23 +506,6 @@ public void StageChange(string org, string repository, string fileName)
}
}
- ///
- /// Halts the merge operation and keeps local changes.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of the repository
- public void AbortMerge(string org, string repository)
- {
- string localServiceRepoFolder = _settings.GetServicePath(org, repository, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext));
- using (LibGit2Sharp.Repository repo = new(localServiceRepoFolder))
- {
- if (repo.RetrieveStatus().IsDirty)
- {
- repo.Reset(ResetMode.Hard, "heads/master");
- }
- }
- }
-
///
public async Task CreateBranch(string org, string repository, string branchName)
{
diff --git a/backend/src/Designer/Services/Implementation/TextsService.cs b/backend/src/Designer/Services/Implementation/TextsService.cs
index 108f8117d89..294f418da7a 100644
--- a/backend/src/Designer/Services/Implementation/TextsService.cs
+++ b/backend/src/Designer/Services/Implementation/TextsService.cs
@@ -97,46 +97,6 @@ public async Task SaveTextV1(string org, string repo, string developer, TextReso
await altinnAppGitRepository.SaveTextV1(languageCode, textResource);
}
- ///
- public async Task> GetTextsV2(string org, string repo, string developer, string languageCode)
- {
- var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
-
- Dictionary jsonTexts = await altinnAppGitRepository.GetTextsV2(languageCode);
-
- List markdownFileNames = ExtractMarkdownFileNames(jsonTexts);
- foreach (string markdownFileName in markdownFileNames)
- {
- string key = markdownFileName.Split('.')[0];
- string text = await altinnAppGitRepository.GetTextMarkdown(markdownFileName);
- jsonTexts[key] = text;
- }
-
- return jsonTexts;
- }
-
- ///
- public async Task> GetKeys(string org, string repo, string developer, IList languages)
- {
- if (languages == null || languages.Count == 0)
- {
- throw new FileNotFoundException();
- }
-
- var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
- Dictionary firstJsonTexts = await altinnAppGitRepository.GetTextsV2(languages[0]);
- languages.RemoveAt(0);
- List allKeys = firstJsonTexts.Keys.ToList();
-
- foreach (string languageCode in languages)
- {
- Dictionary jsonTexts = await altinnAppGitRepository.GetTextsV2(languageCode);
- allKeys = MergeKeys(allKeys, jsonTexts.Keys.ToList());
- }
-
- return allKeys;
- }
-
private static List MergeKeys(List currentSetOfKeys, List keysToMerge)
{
foreach (string key in keysToMerge)
@@ -152,68 +112,6 @@ private static List MergeKeys(List currentSetOfKeys, List
- public async Task UpdateTexts(string org, string repo, string developer, string languageCode, Dictionary jsonTexts)
- {
- var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
-
- (Dictionary, Dictionary) extractMarkdown = ExtractMarkdown(languageCode, jsonTexts);
-
- foreach (KeyValuePair text in extractMarkdown.Item1)
- {
- await altinnAppGitRepository.SaveTextMarkdown(languageCode, text);
- }
-
- await altinnAppGitRepository.SaveTextsV2(languageCode, extractMarkdown.Item2);
- }
-
- ///
- public void DeleteTexts(string org, string repo, string developer, string languageCode)
- {
- var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
-
- altinnAppGitRepository.DeleteTexts(languageCode);
- }
-
- ///
- public async Task ConvertV1TextsToV2(string org, string repo, string developer)
- {
- var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
-
- IEnumerable languageFiles = altinnAppGitRepository.FindFiles(new[] { "resource.*.json" });
-
- foreach (string languageFile in languageFiles.ToList())
- {
- Dictionary newTexts = new();
-
- string languageCode = GetLanguageCodeFromFilePath(languageFile);
- TextResource texts = await altinnAppGitRepository.GetTextV1(languageCode);
-
- foreach (TextResourceElement text in texts.Resources)
- {
- string newText = text.Value;
-
- if (text.Variables != null)
- {
- newText = ConvertText(text);
- }
-
- newTexts[text.Id] = newText;
- }
-
- (Dictionary TextsWithMarkdown, Dictionary Texts) extractMarkdown = ExtractMarkdown(languageCode, newTexts);
-
- foreach (KeyValuePair text in extractMarkdown.TextsWithMarkdown)
- {
- await altinnAppGitRepository.SaveTextMarkdown(languageCode, text);
- }
-
- await UpdateTexts(org, repo, developer, languageCode, extractMarkdown.Texts);
-
- altinnAppGitRepository.DeleteFileByAbsolutePath(languageFile);
- }
- }
-
public async Task UpdateTextsForKeys(string org, string repo, string developer, Dictionary keysTexts, string languageCode)
{
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
@@ -251,59 +149,6 @@ public async Task UpdateTextsForKeys(string org, string repo, string developer,
await altinnAppGitRepository.SaveTextV1(languageCode, textResourceObject);
}
- ///
- public async Task UpdateKey(string org, string repo, string developer, IList languages, string oldKey, string newKey)
- {
- if (languages == null || languages.Count == 0)
- {
- throw new FileNotFoundException();
- }
-
- var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repo, developer);
- Dictionary> tempUpdatedTexts = new(languages.Count);
- bool oldKeyExistsOriginally = false;
- string response = string.Empty;
- try
- {
- foreach (string languageCode in languages)
- {
- Dictionary jsonTexts = await altinnAppGitRepository.GetTextsV2(languageCode);
- oldKeyExistsOriginally = jsonTexts.ContainsKey(oldKey) || oldKeyExistsOriginally;
- if (!string.IsNullOrEmpty(newKey) && jsonTexts.ContainsKey(newKey) && jsonTexts.ContainsKey(oldKey))
- {
- throw new ArgumentException();
- }
-
- if (!string.IsNullOrEmpty(newKey) && jsonTexts.ContainsKey(oldKey))
- {
- string value = jsonTexts[oldKey];
- jsonTexts[newKey] = value;
- }
-
- jsonTexts.Remove(oldKey);
- tempUpdatedTexts[languageCode] = jsonTexts;
- }
-
- response = string.IsNullOrEmpty(newKey) ? $"the key, {oldKey}, was deleted." : $"The old key, {oldKey}, have been replaced with the new key, {newKey}.";
-
- if (!oldKeyExistsOriginally)
- {
- throw new Exception($"The key, {oldKey}, does not exist.");
- }
- }
- catch (ArgumentException)
- {
- throw new ArgumentException();
- }
-
- foreach (KeyValuePair> kvp in tempUpdatedTexts)
- {
- await altinnAppGitRepository.SaveTextsV2(kvp.Key, kvp.Value);
- }
-
- return response;
- }
-
///
public async Task> UpdateRelatedFiles(string org, string app, string developer, List keyMutations)
{
diff --git a/backend/src/Designer/Services/Interfaces/IGitea.cs b/backend/src/Designer/Services/Interfaces/IGitea.cs
index aa16545aed3..5e70cca6f83 100644
--- a/backend/src/Designer/Services/Interfaces/IGitea.cs
+++ b/backend/src/Designer/Services/Interfaces/IGitea.cs
@@ -76,23 +76,6 @@ public interface IGitea
/// A list over organisations
Task> GetUserOrganizations();
- ///
- /// List all branches with commit for a repo
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of the repo
- /// The repoList
- Task> GetBranches(string org, string repo);
-
- ///
- /// Returns information about a given branch
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// The name of repository
- /// Name of branch
- /// The branch info
- Task GetBranch(string org, string repository, string branch);
-
///
/// Creates a new branch in the given repository.
///
diff --git a/backend/src/Designer/Services/Interfaces/ILanguagesService.cs b/backend/src/Designer/Services/Interfaces/ILanguagesService.cs
deleted file mode 100644
index 0436080531c..00000000000
--- a/backend/src/Designer/Services/Interfaces/ILanguagesService.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System.Collections.Generic;
-
-namespace Altinn.Studio.Designer.Services.Interfaces
-{
- ///
- /// Interface for dealing with available languages in an app repository.
- ///
- public interface ILanguagesService
- {
- ///
- /// Returns all languages that exists in a specific repository for a
- /// specific organization by reading the part of all the filenames that
- /// identifies the language under the Texts-directory.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Repository identifier which is unique within an organisation.
- /// Username of developer currently working in the repo.
- /// The languages
- public IList GetLanguages(string org, string repo, string developer);
- }
-}
diff --git a/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs b/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs
index db80bf4b1c4..57316333b64 100644
--- a/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs
+++ b/backend/src/Designer/Services/Interfaces/IProcessModelingService.cs
@@ -1,30 +1,12 @@
-using System.Collections.Generic;
-using System.IO;
+using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Models;
-using NuGet.Versioning;
namespace Altinn.Studio.Designer.Services.Interfaces
{
public interface IProcessModelingService
{
- ///
- /// Gets defined process definition templates for a given version.
- ///
- /// Version of the app-lib
- /// An IEnumerable containing supported templates for given version.
- IEnumerable GetProcessDefinitionTemplates(SemanticVersion version);
-
- ///
- /// Saves the process definition file for a given app from a template.
- ///
- /// An .
- /// Name of the template.
- /// Version of the app-lib.
- /// A that observes if operation is cancelled.
- Task SaveProcessDefinitionFromTemplateAsync(AltinnRepoEditingContext altinnRepoEditingContext, string templateName, SemanticVersion version, CancellationToken cancellationToken = default);
-
///
/// Saves the process definition file for a given app.
///
diff --git a/backend/src/Designer/Services/Interfaces/ISourceControl.cs b/backend/src/Designer/Services/Interfaces/ISourceControl.cs
index 4e11fc1f29b..23b2330e478 100644
--- a/backend/src/Designer/Services/Interfaces/ISourceControl.cs
+++ b/backend/src/Designer/Services/Interfaces/ISourceControl.cs
@@ -81,14 +81,6 @@ public interface ISourceControl
/// List of commits
List Log(string org, string repository);
- ///
- /// Gets initial commit
- ///
- /// Unique identifier of the organisation responsible for the repository.
- /// The name of the repository
- /// The first commits
- Commit GetInitialCommit(string org, string repository);
-
///
/// Gets the latest commit for current user
///
@@ -127,22 +119,6 @@ public interface ISourceControl
/// Information about the commit
void Commit(CommitInfo commitInfo);
- ///
- /// Discards all local changes for the logged in user and the local repository is updated with latest remote commit (origin/master)
- ///
- /// Unique identifier of the organisation responsible for the repository.
- /// The name of the repository
- void ResetCommit(string org, string repository);
-
- ///
- /// Discards local changes to a specific file and the files is updated with latest remote commit (origin/master)
- /// by checking out the specific file
- ///
- /// Unique identifier of the organisation responsible for the repository.
- /// The name of the repository
- /// the name of the file
- void CheckoutLatestCommitForSpecificFile(string org, string repository, string fileName);
-
///
/// Stages a specific file changed in working repository.
///
@@ -151,13 +127,6 @@ public interface ISourceControl
/// the entire file path with filen name
void StageChange(string org, string repository, string fileName);
- ///
- /// Halts the merge operation and keeps local changes
- ///
- /// Unique identifier of the organisation responsible for the repository.
- /// The name of the repository
- void AbortMerge(string org, string repository);
-
///
/// Ensures repository is cloned if not, it clones it.
///
diff --git a/backend/src/Designer/Services/Interfaces/ITextsService.cs b/backend/src/Designer/Services/Interfaces/ITextsService.cs
index 86bd86f382e..b757869a67c 100644
--- a/backend/src/Designer/Services/Interfaces/ITextsService.cs
+++ b/backend/src/Designer/Services/Interfaces/ITextsService.cs
@@ -49,27 +49,6 @@ public interface ITextsService
///
public Task SaveTextV1(string org, string repo, string developer, TextResource textResource, string languageCode);
- ///
- /// Gets texts file in app repository according to
- /// specified languageCode.
- ///
- /// Organisation
- /// Repository
- /// Username of developer
- /// LanguageCode
- /// The text file as a dictionary with ID and text as key:value pairs
- public Task> GetTextsV2(string org, string repo, string developer, string languageCode);
-
- ///
- /// Gets all keys in use across the languages.
- ///
- /// Organisation
- /// Repository
- /// Username of developer
- /// List of languages in application
- /// The text file as a dictionary with ID and text as key:value pairs
- public Task> GetKeys(string org, string repo, string developer, IList languages);
-
///
/// Updates values for
///
@@ -81,45 +60,6 @@ public interface ITextsService
///
public Task UpdateTextsForKeys(string org, string repo, string developer, Dictionary keysTexts, string languageCode);
- ///
- /// Edit texts file for specific language by overwriting old text file.
- ///
- /// Organisation
- /// Repository
- /// Username of developer
- /// LanguageCode
- /// Text to be added to new text file
- public Task UpdateTexts(string org, string repo, string developer, string languageCode, Dictionary jsonTexts);
-
- ///
- /// Deletes texts file for a specific language.
- ///
- /// Unique identifier of the organisation responsible for the app.
- /// Repository identifier which is unique within an organisation.
- /// Username of developer currently working in the repo.
- /// LanguageCode to identify the specific text file.
- public void DeleteTexts(string org, string repo, string developer, string languageCode);
-
- ///
- /// Converts all texts files in a specific repository for a specific organisation.
- ///
- /// Organisation
- /// Repository
- /// Username of developer
- public Task ConvertV1TextsToV2(string org, string repo, string developer);
-
- ///
- /// Updates an old key to a new key in all texts files.
- /// If 'newKey' is undefined the 'oldKey' is deleted.
- ///
- /// Organisation
- /// Repository
- /// Username of developer
- /// All languages that must be updated with new key
- /// The old key that will be replaced
- /// The new key to replace the old
- public Task UpdateKey(string org, string repo, string developer, IList languages, string oldKey, string newKey);
-
///
/// Updates references to text keys in layout files.
///
diff --git a/backend/tests/Designer.Tests/Controllers/KubernetesDeploymentsController/GetKubernetesDeploymentsTests.cs b/backend/tests/Designer.Tests/Controllers/KubernetesDeploymentsController/GetKubernetesDeploymentsTests.cs
deleted file mode 100644
index c4943a9afc2..00000000000
--- a/backend/tests/Designer.Tests/Controllers/KubernetesDeploymentsController/GetKubernetesDeploymentsTests.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Altinn.Studio.Designer.Configuration;
-using Altinn.Studio.Designer.Services.Interfaces;
-using Altinn.Studio.Designer.TypedHttpClients.KubernetesWrapper;
-using Designer.Tests.Controllers.ApiTests;
-using Designer.Tests.Mocks;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Microsoft.Extensions.DependencyInjection;
-using Moq;
-using Xunit;
-
-namespace Designer.Tests.Controllers.KubernetesDeploymentsController;
-
-public class GetKubernetesDeployments : DesignerEndpointsTestsBase, IClassFixture>
-{
- private readonly Mock _kubernetesDeploymentsMock = new Mock();
- private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/kubernetesdeployments";
- public GetKubernetesDeployments(WebApplicationFactory factory) : base(factory)
- {
- }
-
- protected override void ConfigureTestServices(IServiceCollection services)
- {
- services.Configure(c =>
- c.RepositoryLocation = TestRepositoriesLocation);
- services.AddSingleton();
- services.AddSingleton(_ => _kubernetesDeploymentsMock.Object);
- }
-
- [Theory]
- [InlineData("ttd", "issue-6094")]
- public async Task GetKubernetesDeployments_OK(string org, string app)
- {
- // Arrange
- string uri = VersionPrefix(org, app);
- List kubernetesDeployments = GetDeployments("completedDeployments.json");
-
- _kubernetesDeploymentsMock
- .Setup(rs => rs.GetAsync(org, app))
- .ReturnsAsync(kubernetesDeployments);
-
- using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri);
-
- // Act
- HttpResponseMessage res = await HttpClient.SendAsync(httpRequestMessage);
- string responseString = await res.Content.ReadAsStringAsync();
- List actual = JsonSerializer.Deserialize>(responseString, JsonSerializerOptions);
-
- // Assert
- Assert.Equal(HttpStatusCode.OK, res.StatusCode);
- Assert.Equal(2, actual.Count);
- }
-
- private List GetDeployments(string filename)
- {
- string path = Path.Combine(UnitTestsFolder, "..", "..", "..", "_TestData", "KubernetesDeployments", filename);
- if (!File.Exists(path))
- {
- return null;
- }
-
- string deployments = File.ReadAllText(path);
- return JsonSerializer.Deserialize>(deployments, JsonSerializerOptions);
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/LanguagesController/GetLanguagesTests.cs b/backend/tests/Designer.Tests/Controllers/LanguagesController/GetLanguagesTests.cs
deleted file mode 100644
index 4f488071066..00000000000
--- a/backend/tests/Designer.Tests/Controllers/LanguagesController/GetLanguagesTests.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Collections.Generic;
-using System.Net;
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.LanguagesController
-{
- public class GetLanguagesTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- private readonly string _versionPrefix = "designer/api";
-
- public GetLanguagesTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Fact]
- public async Task GetLanguages_ReturnsNnAndNb()
- {
- string dataPathWithData = $"{_versionPrefix}/ttd/new-texts-format/languages";
- HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- string responseBody = await response.Content.ReadAsStringAsync();
- JsonDocument responseDocument = JsonDocument.Parse(responseBody);
- List responseList = JsonSerializer.Deserialize>(responseDocument.RootElement.ToString());
-
- Assert.Equal(new List { "nb", "nn" }, responseList);
- }
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs
deleted file mode 100644
index 4aded182962..00000000000
--- a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Collections.Generic;
-using System.Net;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.ProcessModelingController
-{
- public class GetTemplatesTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- private static string VersionPrefix(string org, string repository, string appVersion) => $"/designer/api/{org}/{repository}/process-modelling/templates/{appVersion}";
-
- public GetTemplatesTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "empty-app", "8.0.0", "start-data-confirmation-end.bpmn", "start-data-confirmation-feedback-end.bpmn", "start-data-end.bpmn", "start-data-signing-end.bpmn")]
- [InlineData("ttd", "empty-app", "8.0.0-preview.11", "start-data-confirmation-end.bpmn", "start-data-confirmation-feedback-end.bpmn", "start-data-end.bpmn", "start-data-signing-end.bpmn")]
- [InlineData("ttd", "empty-app", "7.4.0", "start-data-confirmation-end.bpmn", "start-data-data-data-end.bpmn", "start-data-end.bpmn")]
- [InlineData("ttd", "empty-app", "6.1.0")]
- public async Task GetTemplates_ShouldReturnOK(string org, string app, string version, params string[] expectedTemplates)
- {
- string url = VersionPrefix(org, app, version);
-
- using var response = await HttpClient.GetAsync(url);
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
-
- List responseContent = await response.Content.ReadAsAsync>();
-
- Assert.Equal(expectedTemplates.Length, responseContent.Count);
- foreach (string expectedTemplate in expectedTemplates)
- {
- Assert.Contains(expectedTemplate, responseContent);
- }
- }
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs b/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs
deleted file mode 100644
index 5bbd5922405..00000000000
--- a/backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System.Net;
-using System.Threading.Tasks;
-using System.Xml.Linq;
-using Designer.Tests.Controllers.ApiTests;
-using Designer.Tests.Utils;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.ProcessModelingController
-{
- public class SaveProcessDefinitionFromTemplateTests : DesignerEndpointsTestsBase, IClassFixture>
- {
-
- private static string VersionPrefix(string org, string repository, string appVersion, string templateName) => $"/designer/api/{org}/{repository}/process-modelling/templates/{appVersion}/{templateName}";
-
- public SaveProcessDefinitionFromTemplateTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "empty-app", "testUser", "9.0.0", "start-data-confirmation-end.bpmn")]
- public async Task SaveProcessDefinitionFromTemplate_WrongTemplate_ShouldReturn404(string org, string app, string developer, string version, string templateName)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
-
- string url = VersionPrefix(org, targetRepository, version, templateName);
-
- using var response = await HttpClient.PutAsync(url, null);
- Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
- }
-
- [Theory]
- [InlineData("ttd", "empty-app", "testUser", "8.0.0", "start-data-confirmation-end.bpmn")]
- [InlineData("ttd", "empty-app", "testUser", "8.0.0-preview.11", "start-data-confirmation-end.bpmn")]
- public async Task SaveProcessDefinitionFromTemplate_ShouldReturnOk_AndSaveTemplate(string org, string app, string developer, string version, string templateName)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
-
- string url = VersionPrefix(org, targetRepository, version, templateName);
-
- using var response = await HttpClient.PutAsync(url, null);
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
-
- string responseContent = await response.Content.ReadAsStringAsync();
-
- string savedFile = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, "App/config/process/process.bpmn");
-
- XDocument responseXml = XDocument.Parse(responseContent);
- XDocument savedXml = XDocument.Parse(savedFile);
- Assert.True(XNode.DeepEquals(savedXml, responseXml));
- }
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/TextKeysController/GetTests.cs b/backend/tests/Designer.Tests/Controllers/TextKeysController/GetTests.cs
deleted file mode 100644
index 8847a560756..00000000000
--- a/backend/tests/Designer.Tests/Controllers/TextKeysController/GetTests.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System.Collections.Generic;
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Designer.Tests.Utils;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.TextKeysController
-{
- public class GetTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text-keys";
- public GetTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "keys-management", "testUser", 9)]
- public async Task Get_Keys_200Ok(string org, string app, string developer, int expectedKeyNumber)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = VersionPrefix(org, targetRepository);
- HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
-
- string content = await response.Content.ReadAsStringAsync();
- List keys = JsonSerializer.Deserialize>(content);
-
- Assert.Equal(expectedKeyNumber, keys.Count);
- }
-
- [Theory]
- [InlineData("ttd", "empty-app", "testUser")]
- public async Task GetKeys_TextsFilesNotFound_404NotFound(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = VersionPrefix(org, targetRepository);
- HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- Assert.Equal(StatusCodes.Status404NotFound, (int)response.StatusCode);
- }
-
- [Theory]
- [InlineData("ttd", "invalid-texts-and-ruleconfig", "testUser")]
- public async Task GetKeys_TextsFileInvalidFormat_500InternalServerError(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = VersionPrefix(org, targetRepository);
- HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
-
- Assert.Equal(StatusCodes.Status500InternalServerError, (int)response.StatusCode);
- }
-
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/TextKeysController/PutTests.cs b/backend/tests/Designer.Tests/Controllers/TextKeysController/PutTests.cs
deleted file mode 100644
index 3499bc67ebb..00000000000
--- a/backend/tests/Designer.Tests/Controllers/TextKeysController/PutTests.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using System.Collections.Generic;
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Designer.Tests.Utils;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.TextKeysController
-{
- public class PutTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- private static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/text-keys";
- public PutTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "keys-management", "testUser")]
- public async Task PutNewKey_OldKeyPresentInAllFiles_200OkAndNewKeyPresent(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=AlreadyExistingKey&newKey=ReplacedKey";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string urlGetKeys = VersionPrefix(org, targetRepository);
- HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys);
- HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest);
- string list = await responseGetKeys.Content.ReadAsStringAsync();
- List keys = JsonSerializer.Deserialize>(list);
-
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- Assert.Equal(7, keys.IndexOf("ReplacedKey"));
- }
-
- [Theory]
- [InlineData("ttd", "keys-management", "testUser")]
- public async Task Put_NewKeyExistInOneFileOldKeyExistInAnotherFile_200OkAndOneLessTotalKeys(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=KeyNotDefinedInEnglish&newKey=KeyOnlyDefinedInEnglish";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string urlGetKeys = VersionPrefix(org, targetRepository);
- HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys);
- HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest);
- string list = await responseGetKeys.Content.ReadAsStringAsync();
- List keys = JsonSerializer.Deserialize>(list);
-
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- Assert.Equal(8, keys.Count);
- }
-
- [Theory]
- [InlineData("ttd", "keys-management", "testUser")]
- public async Task Put_NewKeyExistInSameFileAsOldKey_400BadRequestNoFilesChanged(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=AlreadyExistingKey&newKey=KeyOnlyDefinedInEnglish";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string urlGetKeys = VersionPrefix(org, targetRepository);
- HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys);
- HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest);
- string list = await responseGetKeys.Content.ReadAsStringAsync();
- List keys = JsonSerializer.Deserialize>(list);
-
- Assert.Equal(StatusCodes.Status400BadRequest, (int)response.StatusCode);
- Assert.Contains("AlreadyExistingKey", keys);
- }
-
- [Theory]
- [InlineData("ttd", "keys-management", "testUser")]
- public async Task Put_EmptyNewKey_200OkOldKeyIsRemoved(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=AlreadyExistingKey&newKey=";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string urlGetKeys = VersionPrefix(org, targetRepository);
- HttpRequestMessage urlGetKeysRequest = new(HttpMethod.Get, urlGetKeys);
- HttpResponseMessage responseGetKeys = await HttpClient.SendAsync(urlGetKeysRequest);
- string list = await responseGetKeys.Content.ReadAsStringAsync();
- List keys = JsonSerializer.Deserialize>(list);
-
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- Assert.Equal(8, keys.Count);
- Assert.DoesNotContain("AlreadyExistingKey", keys);
- }
-
- [Theory]
- [InlineData("ttd", "empty-app", "testUser")]
- public async Task Put_TextsFilesNotFound_404NotFound(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?oldKey=KeyNotDefinedInEnglish&newKey=KeyOnlyDefinedInEnglish";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
-
- Assert.Equal(StatusCodes.Status404NotFound, (int)response.StatusCode);
- }
-
- [Theory]
- [InlineData("ttd", "keys-management", "testUser")]
- public async Task Put_IllegalArguments_400BadRequest(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}?wrongQueryParam=KeyNotDefinedInEnglish&newKey=KeyOnlyDefinedInEnglish";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
-
- Assert.Equal(StatusCodes.Status400BadRequest, (int)response.StatusCode);
- }
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/ConvertTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/ConvertTests.cs
deleted file mode 100644
index e3c26379cb9..00000000000
--- a/backend/tests/Designer.Tests/Controllers/TextsController/ConvertTests.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Net;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Designer.Tests.Utils;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.TextsController
-{
- public class ConvertTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts";
- public ConvertTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "convert-texts", "testUser")]
- public async Task Put_ConvertTexts_204NoContent(string org, string app, string developer)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}/convert";
- using HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, dataPathWithData);
- using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
-
- Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
- }
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/DeleteTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/DeleteTests.cs
deleted file mode 100644
index 7bead30cec6..00000000000
--- a/backend/tests/Designer.Tests/Controllers/TextsController/DeleteTests.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Designer.Tests.Utils;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.TextsController
-{
- public class DeleteTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts";
- public DeleteTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "new-texts-format", "testUser", "nb")]
- [InlineData("ttd", "markdown-files", "testUser", "nb")]
- public async Task Delete_200Ok(string org, string app, string developer, string lang)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Delete, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string responseBody = await response.Content.ReadAsStringAsync();
- JsonDocument responseDocument = JsonDocument.Parse(responseBody);
-
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- Assert.Equal("Texts file, nb.texts.json, was successfully deleted.", responseDocument.RootElement.ToString());
- }
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/GetTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/GetTests.cs
deleted file mode 100644
index 33cc95b504e..00000000000
--- a/backend/tests/Designer.Tests/Controllers/TextsController/GetTests.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System.Collections.Generic;
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.TextsController
-{
- public class GetTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts";
- public GetTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "new-texts-format", "nb")]
- public async Task Get_ReturnsNbTexts(string org, string app, string lang)
- {
- string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- response.EnsureSuccessStatusCode();
- string responseBody = await response.Content.ReadAsStringAsync();
- JsonDocument responseDocument = JsonDocument.Parse(responseBody);
- Dictionary responseDictionary = JsonSerializer.Deserialize>(responseDocument.RootElement.ToString());
-
- Dictionary expectedDictionary = new Dictionary
- { { "nb_key1", "nb_value1" }, { "nb_key2", "nb_value2" } };
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- Assert.Equal(expectedDictionary, responseDictionary);
- }
-
- [Theory]
- [InlineData("ttd", "new-texts-format", "nb")]
- public async Task Get_Markdown_200Ok(string org, string app, string lang)
- {
- string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
-
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- }
-
- [Theory]
- [InlineData("ttd", "new-texts-format", "uk")]
- public async Task Get_NonExistingFile_404NotFound(string org, string app, string lang)
- {
- string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string responseBody = await response.Content.ReadAsStringAsync();
- JsonDocument responseDocument = JsonDocument.Parse(responseBody);
-
- Assert.Equal(StatusCodes.Status404NotFound, (int)response.StatusCode);
- Assert.Equal("The texts file, uk.texts.json, that you are trying to find does not exist.", responseDocument.RootElement.ToString());
- }
-
- [Theory]
- [InlineData("ttd", "invalid-texts-and-ruleconfig", "en")]
- public async Task Get_InvalidFile_500InternalServer(string org, string app, string lang)
- {
- string dataPathWithData = $"{VersionPrefix(org, app)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, dataPathWithData);
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string responseBody = await response.Content.ReadAsStringAsync();
- JsonDocument responseDocument = JsonDocument.Parse(responseBody);
- Dictionary responseDictionary = JsonSerializer.Deserialize>(responseDocument.RootElement.ToString());
-
- Assert.Equal(StatusCodes.Status500InternalServerError, (int)response.StatusCode);
- Assert.Equal("The format of the file, en.texts.json, that you tried to access might be invalid.", responseDictionary["errorMessage"]);
- }
- }
-}
diff --git a/backend/tests/Designer.Tests/Controllers/TextsController/PutTests.cs b/backend/tests/Designer.Tests/Controllers/TextsController/PutTests.cs
deleted file mode 100644
index 1d8e13a5a1f..00000000000
--- a/backend/tests/Designer.Tests/Controllers/TextsController/PutTests.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System.Net.Http;
-using System.Net.Http.Json;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Designer.Tests.Controllers.ApiTests;
-using Designer.Tests.Utils;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.Testing;
-using Xunit;
-
-namespace Designer.Tests.Controllers.TextsController
-{
- public class PutTests : DesignerEndpointsTestsBase, IClassFixture>
- {
- protected static string VersionPrefix(string org, string repository) => $"/designer/api/{org}/{repository}/texts";
- public PutTests(WebApplicationFactory factory) : base(factory)
- {
- }
-
- [Theory]
- [InlineData("ttd", "new-texts-format", "testUser", "nb")]
- public async Task Put_UpdateNbTexts_200OK(string org, string app, string developer, string lang)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
- httpRequestMessage.Content = JsonContent.Create(new
- {
- new_key_1 = "new_value_1",
- new_key_2 = "new_value_2"
- });
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
-
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- }
-
- [Theory]
- [InlineData("ttd", "markdown-files", "testUser", "nb")]
- public async Task Put_Markdown_200OK(string org, string app, string developer, string lang)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, dataPathWithData);
- httpRequestMessage.Content = JsonContent.Create(new
- {
- markdown_key = "## This is a markdown text \n\n Here is a list \n - Item1 \n - Item2 \n - Item3 \n\n # HERE IS SOME IMPORTANT CODE \n `print(Hello world)`"
- });
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
-
- Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);
- }
-
- [Theory]
- [InlineData("ttd", "new-texts-format", "testUser", "nb")]
- public async Task Put_UpdateInvalidFormat_400BadRequest(string org, string app, string developer, string lang)
- {
- string targetRepository = TestDataHelper.GenerateTestRepoName();
- await CopyRepositoryForTest(org, app, developer, targetRepository);
- string dataPathWithData = $"{VersionPrefix(org, targetRepository)}/language/{lang}";
- HttpRequestMessage httpRequestMessage = new(HttpMethod.Put, dataPathWithData);
- httpRequestMessage.Content = JsonContent.Create(new
- {
- valid_key = "valid_value",
- invalid_key = new
- {
- invalid_format = "invalid_format"
- }
- });
-
- HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage);
- string responseBody = await response.Content.ReadAsStringAsync();
- JsonDocument responseDocument = JsonDocument.Parse(responseBody);
-
- Assert.Equal(StatusCodes.Status400BadRequest, (int)response.StatusCode);
- Assert.Equal("The texts file, nb.texts.json, that you are trying to add have invalid format.", responseDocument.RootElement.ToString());
- }
-
- }
-}
diff --git a/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryController/RepositoryControllerGiteaIntegrationTests.cs b/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryController/RepositoryControllerGiteaIntegrationTests.cs
index 59a2dc213c7..d84f7ce7e17 100644
--- a/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryController/RepositoryControllerGiteaIntegrationTests.cs
+++ b/backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryController/RepositoryControllerGiteaIntegrationTests.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
@@ -105,20 +104,6 @@ public async Task Pull_ShouldBeAsExpected(string org)
Assert.True(File.Exists($"{CreatedFolderPath}/test2.txt"));
}
- [Theory]
- [InlineData(GiteaConstants.TestOrgUsername)]
- public async Task Initial_Commit_ShouldBeAsExpected(string org)
- {
- string targetRepo = TestDataHelper.GenerateTestRepoName("-gitea");
- await CreateAppUsingDesigner(org, targetRepo);
-
- // Check initial-commit endpoint
- using HttpResponseMessage initialCommitResponse = await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/initial-commit");
- Assert.Equal(HttpStatusCode.OK, initialCommitResponse.StatusCode);
- var commit = await initialCommitResponse.Content.ReadAsAsync();
- Assert.Contains("App created", commit.Message);
- }
-
[Theory]
[InlineData(GiteaConstants.TestOrgUsername)]
public async Task MetadataAndStatus_ShouldBehaveAsExpected(string org)
@@ -164,27 +149,6 @@ public async Task GetOrgRepos_ShouldBehaveAsExpected(string org)
Assert.Contains(deserializedRepositoryModel, x => x.Name == targetRepo);
}
- // Get branch endpoint test
- [Theory]
- [InlineData(GiteaConstants.TestOrgUsername)]
- public async Task GetBranches_And_Branch_ShouldBehaveAsExpected(string org)
- {
- string targetRepo = TestDataHelper.GenerateTestRepoName("-gitea");
- await CreateAppUsingDesigner(org, targetRepo);
-
- // Call branches endpoint
- using HttpResponseMessage branchesResponse = await _giteaRetryPolicy.ExecuteAsync(async () => await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/branches"));
- Assert.Equal(HttpStatusCode.OK, branchesResponse.StatusCode);
- var deserializedBranchesModel = await branchesResponse.Content.ReadAsAsync>();
- Assert.Single(deserializedBranchesModel);
- Assert.Equal("master", deserializedBranchesModel.First().Name);
-
- // Call branch endpoint
- using HttpResponseMessage branchResponse = await _giteaRetryPolicy.ExecuteAsync(async () => await HttpClient.GetAsync($"designer/api/repos/repo/{org}/{targetRepo}/branches/branch?branch=master"));
- Assert.Equal(HttpStatusCode.OK, branchResponse.StatusCode);
- }
-
-
[Theory]
[InlineData(GiteaConstants.TestOrgUsername)]
public async Task PushWithConflictingChangesRemotely_ShouldReturnConflict(string org)
diff --git a/backend/tests/Designer.Tests/Mocks/IGiteaMock.cs b/backend/tests/Designer.Tests/Mocks/IGiteaMock.cs
index f717e8efbda..3416b8e72be 100644
--- a/backend/tests/Designer.Tests/Mocks/IGiteaMock.cs
+++ b/backend/tests/Designer.Tests/Mocks/IGiteaMock.cs
@@ -45,16 +45,6 @@ public Task DeleteRepository(string org, string repository)
return Task.FromResult(true);
}
- public Task GetBranch(string org, string repository, string branch)
- {
- throw new NotImplementedException();
- }
-
- public Task> GetBranches(string org, string repo)
- {
- throw new NotImplementedException();
- }
-
public Task GetCurrentUser()
{
return Task.FromResult(new User());
diff --git a/backend/tests/Designer.Tests/Mocks/ISourceControlMock.cs b/backend/tests/Designer.Tests/Mocks/ISourceControlMock.cs
index 7724c9c6b39..7ac3c511204 100644
--- a/backend/tests/Designer.Tests/Mocks/ISourceControlMock.cs
+++ b/backend/tests/Designer.Tests/Mocks/ISourceControlMock.cs
@@ -20,16 +20,6 @@ public ISourceControlMock(string developer = "testUser")
_developer = developer;
}
- public void AbortMerge(string org, string repository)
- {
- throw new NotImplementedException();
- }
-
- public void CheckoutLatestCommitForSpecificFile(string org, string repository, string fileName)
- {
- throw new NotImplementedException();
- }
-
public int? CheckRemoteUpdates(string org, string repository)
{
throw new NotImplementedException();
@@ -101,11 +91,6 @@ public Task GetDeployToken()
throw new NotImplementedException();
}
- public Commit GetInitialCommit(string org, string repository)
- {
- throw new NotImplementedException();
- }
-
public Commit GetLatestCommitForCurrentUser(string org, string repository)
{
throw new NotImplementedException();
@@ -149,11 +134,6 @@ public RepoStatus RepositoryStatus(string org, string repository)
throw new NotImplementedException();
}
- public void ResetCommit(string org, string repository)
- {
- throw new NotImplementedException();
- }
-
public void StageChange(string org, string repository, string fileName)
{
throw new NotImplementedException();
diff --git a/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs b/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs
index 0607c5f620b..31ca1c4f5b9 100644
--- a/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs
+++ b/backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs
@@ -1,6 +1,4 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
using Altinn.Studio.Designer.Factories;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Implementation;
@@ -8,7 +6,6 @@
using Altinn.Studio.Designer.Services.Interfaces;
using Designer.Tests.Utils;
using Moq;
-using NuGet.Versioning;
using SharedResources.Tests;
using Xunit;
@@ -27,24 +24,6 @@ public ProcessModelingServiceTests()
_appDevelopmentService = new AppDevelopmentService(_altinnGitRepositoryFactory, schemaModelServiceMock.Object);
}
- [Theory]
- [MemberData(nameof(TemplatesTestData))]
- public void GetProcessDefinitionTemplates_GivenVersion_ReturnsListOfTemplates(string versionString, params string[] expectedTemplates)
- {
- SemanticVersion version = SemanticVersion.Parse(versionString);
-
- IProcessModelingService processModelingService = new ProcessModelingService(new Mock().Object, _appDevelopmentService);
-
- var result = processModelingService.GetProcessDefinitionTemplates(version).ToList();
-
- Assert.Equal(expectedTemplates.Length, result.Count);
-
- foreach (string expectedTemplate in expectedTemplates)
- {
- Assert.Contains(expectedTemplate, result);
- }
- }
-
[Theory]
[InlineData("ttd", "app-with-process-and-layoutsets", "testUser")]
public async Task GetTaskTypeFromProcessDefinition_GivenProcessDefinition_ReturnsTaskType(string org, string app, string developer)
@@ -61,32 +40,5 @@ public async Task GetTaskTypeFromProcessDefinition_GivenProcessDefinition_Return
// Assert
Assert.Equal("data", taskType);
}
-
- public static IEnumerable