Last modified: May 28, 2024

Development

Swagger

We use Swagger to document our APIs. Swashbuckle We use Swashbuckle to generate the documentation. Further documentation on Swashbuckle.AspNetCore is available here The configurations described below are all located in Program.cs in the AddSwaggerGen method. Configure authorization Most of our APIs requires authorization. To enable the end user to test these endpoints through Swagger support for authentication must be configured. Authorization box in Swagger The authorization box above is created with the configuration below. »

Test

Coding guidelines for tests App for automated testAn app used solely for automated testing in the browser CypressFunctional Testing of Altinn Studio and Altinn app-frontend with Cypress k6Performance and Functional Testing of API with K6 PostmanAPI Testing with postman Test StrategyTest Strategy Unit testing with JestHow to write jest test in altinn studio, what we know so far. This page summarizes how UI testing is performed with Jest and related libraries for Altinn Studio. »

Test Strategy

What should be tested? In tjenester 3.0, there is a need for both testing Altinn Studio, the app designer, as well as testing apps that are developed by an app developer in Altinn Studio Runtime. Testing these two areas of Altinn Studio requires different approaches. Testing of Altinn Studio is to be tested automatically at the unit and integration levels of testing. Unit testing of the system involves, for example, the testing of individual javascript functions, and individual pieces of logic relating to react/UI components. »

TLS in Traefik 2.0

TLS sertificates stored as secrets on the cluster apiVersion: v1 kind: Secret metadata: name: altinn-tls-secret data: tls.crt: [[BASE 64 ENCODED CERTIFICATE]] tls.key: [[BASE 64 ENCODED PRIVATE KEY]] TLS Options To set up TLS options we need to use the custom resource TLSOption. A basic set up of this is: apiVersion: traefik.containo.us/v1alpha1 kind: TLSOption metadata: name: altinn-tls-options namespace: default spec: minVersion: VersionTLS12 Adding TLS to an Ingress Route Add a tls attribute to the spec if the ingress route, with secretName (secret that contains the TLS certificate and private key) and optionally a options-attribute with the name of the TLSOption we made and the namespace (if nothing is specified when creating the secret it would be in the default namespace). »

Traefik custom resources

IMPORTANT These resources have to be installed before creating any of the resources they describe. They are most likely installed with helm when installing traefik 2.0. To support new features in routing and middlewares with IngressRoutes and dynamic tls options, traefik supplies it’s own kubernetes custom resources defined in the traefik docs. These are: apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: name: ingressroutes.traefik.containo.us spec: group: traefik.containo.us version: v1alpha1 names: kind: IngressRoute plural: ingressroutes singular: ingressroute scope: Namespaced --- apiVersion: apiextensions. »

Traefik ingress routes

Before traefik 2.0 the only supported way of routing in kubernetes was through the Kubernetes Ingress prodvider, which limited the functionality traefik could offer. As a result of introducing the custom resource IngressRoutes in traefik 2.0 we don’t need to write many annotations on the ingress. And it is easier to configure access to a kubernetes cluster. Resource configuration apiVersion: traefik.containo.us/v1alpha1 kind: IngressRoute metadata: name: altinn-runtime spec: entryPoints: - web - websecure routes: - match: Host(`dev. »

Traefik routing

In Altinn Tjenester 3.0 we are migrating from nginx to traefik for routing. Installation of Traefik 2.0How to install traefik TLS in Traefik 2.0How to set up TLS Traefik custom resourcesDefinitions for traefik 2.0 custom resources in kubernetes Traefik ingress routesHow to set up an ingress route and route trafic based on rules and middlewares »

Unit testing with Jest

When should you write tests? Unit testing includes testing of javascript functions and react/UI components. Listing of the highest priority of unit-testing: API calls with the correct formatted parameters Rendering of isolated components. Functions in general. Exporting and importing your component A quick way to get started testing your component is first to export the React Component: export class CloneServiceComponent extends React.Component<ICloneServiceComponentProps & RouteChildrenProps, ICloneServiceComponentState> { and then reference it in your test the following way: »

Versioning

The frontends, both for Altinn Studio and Apps are set up as node modules, using a package.json to import external dependencies. In package.json for each package we can specify the version of the package. In this context, package refers to the different applications we are bulding, such as altinn-app-frontend, receipt, etc. Each time we make a change to a package, we need to update the version of the package to reflect the change. »