Commit ba8e7798 authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge branch '2025Q4_RC' into 'main'

Creating 2025Q4 Release

Closes #39

See merge request !39
parents b41f51bd 3fab05e3
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ npm-debug.log
yarn-error.log
testem.log
/typings
.env
cypress/fixtures
cypress/screenshots
cypress/downloads

# System Files
.DS_Store
@@ -50,3 +54,4 @@ src/assets/config/config.theming.json
/src/assets/config/theming.scss
/.angular
/.tmp/
/proxy.conf.json
+109 −59
Original line number Diff line number Diff line
# org.etsi.osl.tmf.web

# OpenSlice TMF Web UI

This document serves as the primary reference for setting up, configuring, and running the TMF Web UI, an Angular application that consumes the TMF API.

## Getting started
## Requirements

To make it easy for you to get started with GitLab, here's a list of recommended next steps.
To ensure a consistent development environment and avoid compatibility issues, please use the following versions for the main tools.

Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!

## Add your files

- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
| Tool                           	| Version   	| Notes                                                               	|   	
|--------------------------------	|-----------	|---------------------------------------------------------------------	|
| **Node Version Manager (nvm)** 	| Latest    	| Recommended for managing Node versions. [Guide](https://www.freecodecamp.org/news/node-version-manager-nvm-install-guide/) |
| **Node.js**                    	| `18.20.8` 	| Managed via `nvm`. Use `nvm install 18.20.8` and `nvm use 18.20.8`. 	|
| **Angular CLI**                	| `14.x.x`  	| Install globally using `npm install -g @angular/cli@14`.            	|   

## Configuration

Configuration files allow customization of the application's behavior, styling, and appearance without altering the core codebase.

All primary configuration files are located in the following directory:

`./src/assets/config/`

The configuration files for the end to end testing are located in the following directory:
`./cypress/`

### Default Configuration Files (Templates)

The following files serve as templates for customizing the environment:

| Filename                           	| Purpose   	| Description                                               |  Location                	|   	
|--------------------------------	|-----------	|---------------------------------------------------------------------	| ------------- 
| `config.prod.default.json` 	| **API & Basic Info**    	| Contains core application information, environment variables, and essential API endpoint configurations for the production environment.                             	|  `./src/assets/config/`
| `theming.default.scss`                    	| **CSS Theming** 	| Defines the SCSS variables for the application's color palette |  `./src/assets/config/`
| `config.theming.default.json`       	| **HTML Configuration**	| Contains configurations for static UI elements like the application Logo URL, Favicon path, and dynamic content for the Footer.            	|   `./src/assets/config/`
|  `default.env`      |  **E2E Testing**    |  Contains default environment variables required for running Cypress End-to-End tests.  |  `./cypress/`






### Configuration Setup (Mandatory Renaming)

Before running or building the project, you **must** create copies of the template files, removing the `.default` suffix, as these are mandatory for the application to properly load its settings.

The resulting files required for initial setup are:

| Filename                           	| Status | Purpose                                                               	|  Location    	
|--------------------------------	|-----------	|---------------------------------------------------------------------	| --------- |
| `config.prod.json` 	| **Mandatory**    	| The application's main configuration. (Copy of `config.prod.default.json`)      	|  `./src/assets/config/`
| `theming.scss`                    	| **Mandatory** 	| The primary SCSS theming file. (Copy of `theming.default.scss`) |  `./src/assets/config/`
| `config.theming.json`       	| _Optional_	| HTML configuration for branding. (Copy of `config.theming.default.json`)    	|  `./src/assets/config/` 
|  `.env`  | **Mandatory (for testing)**  |  The active environment configuration for Cypress. (Copy/Rename of default.env)  | `./cypress/`



## Serving the Application

To run the application locally, ensure you have completed the **Configuration Setup**

### Initial Setup (Dependencies)

First, install the necessary project dependencies:

```
cd existing_repo
git remote add origin https://labs.etsi.org/rep/osl/code/org.etsi.osl.tmf.web.git
git branch -M main
git push -uf origin main
npm i
```

## Integrate with your tools
This command downloads all dependencies defined in `package.json` and `package-lock.json`.

- [ ] [Set up project integrations](https://labs.etsi.org/rep/osl/code/org.etsi.osl.tmf.web/-/settings/integrations)
### A. Production/Default Serve (AOT)

## Collaborate with your team
This method uses **Ahead-of-Time (AOT)** compilation, which pre-compiles Angular templates into JavaScript during the build process. This is often used for final checks and mimics the production build process.

- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
To run:

## Test and Deploy
```
ng serve --configuration production
```

Once compiled, open your browser and navigate to: [http://localhost:4200](https://www.google.com/search?q=http://localhost:4200 "null")

Use the built-in continuous integration in GitLab.
### B. Development Serve (JIT)

- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
For active development, using **Just-in-Time (JIT)** compilation is strongly encouraged. JIT compiles templates in the browser at runtime, resulting in significantly faster build times and rapid live reloads after code changes.

***
1.  **Create Development Config:** To use this mode, you must first create a specific development configuration file:
    
    ```
    cp src/assets/config/config.prod.json src/assets/config/config.dev.json
    ```
    
# Editing this README
2.  **Run JIT Serve:** Execute the serve command using the new development configuration:
    
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
    ```
    ng serve --configuration development
    ```
    
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.

## Name
Choose a self-explaining name for your project.
**Important Development Note:** While JIT mode is great for iteration speed, AOT compilation runs a more comprehensive check. After development and before committing, it is highly recommended to perform at least one test run using the AOT configuration (`ng serve --configuration production`) to ensure no template or dependency issues are present in the full build.

## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Building the Project

## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
To create a deployable package containing optimized JavaScript, CSS, and HTML assets, use the build command.

## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
### Build Command (Production)

## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
Assuming all configurations are set and dependencies are installed (`npm i`), execute:

## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
```
ng build --configuration production
```

## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
### Output

## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
The compiled, production-ready assets will be generated in the `/dist` directory within the project root. This directory contains the static files ready for deployment on any web server.

## Contributing
State if you are open to contributions and what your requirements are for accepting them.
## Running Tests (Cypress)

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
This project uses Cypress for End-to-End (E2E) testing.

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
### Prerequisites
*Environment Variables*: Ensure you have created the `.env` file in the `./cypress/` directory as specified in the **Configuration Setup** table above.

## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
### Interactive Mode (Test Runner)
Use this mode for developing tests. It opens the Cypress Test Runner UI, allowing you to select and watch tests run in a real browser

## License
For open source projects, say how it is licensed.
```
npm run cy:open
```
1. Select E2E Testing.
2. Choose your preferred browser (e.g. Chrome, Electron).
3. Click on a spec file (e.g. auth.cy.ts) to run it.

## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
### Headless Mode
Use this mode to run all tests in the terminal without opening a browser window.
```
npm run cy:run
```
 No newline at end of file

cypress.config.ts

0 → 100644
+31 −0
Original line number Diff line number Diff line
import { defineConfig } from "cypress";
import * as dotenv from "dotenv";

dotenv.config( { path: 'cypress/.env'});

export default defineConfig({
  
  e2e: {
    setupNodeEvents(on, config) {
      require("ts-node").register({
        project: "tsconfig.json",
      });
      return config;
    },
    baseUrl: process.env.CYPRESS_BASE_URL,
    pageLoadTimeout: 16000,
    viewportWidth: 1500,
    viewportHeight: 900,
    env: {
      username: process.env.CYPRESS_username,
      password: process.env.CYPRESS_password,
      authURL: process.env.CYPRESS_AUTH_URL,
      authRealm: process.env.CYPRESS_AUTH_REALM,
      resetCredentials: process.env.CYPRESS_RESET_CREDENTIALS,
      registration: process.env.CYPRESS_REGISTRATION

      
    }
  },
});

cypress/default.env

0 → 100644
+7 −0
Original line number Diff line number Diff line
CYPRESS_username=admin
CYPRESS_password=openslice
CYPRESS_BASE_URL=http://localhost:4200/
CYPRESS_AUTH_URL=https://portal.openslice.eu/
CYPRESS_AUTH_REALM=/auth/realms/openslice/protocol/openid-connect/auth
CYPRESS_RESET_CREDENTIALS=/auth/realms/openslice/login-actions/reset-credentials
CYPRESS_REGISTRATION=/auth/realms/openslice/login-actions/registration
 No newline at end of file

cypress/e2e/auth.cy.ts

0 → 100644
+131 −0
Original line number Diff line number Diff line
describe("user authentication", () => {
  beforeEach(() => {
    cy.visit(window.location.origin);
  });

  it("should block unauthenticated user from entering a protected route", () => {
    cy.fixture("routes.json").then((data) => {
      cy.log(data.routes);
      for (let route of data.routes) {
        cy.intercept(route);
        cy.log(route);
        cy.visit(route);
        cy.location("pathname").should("equal", "/");
      }
    });
  });
  it("should display login errors when nothing is typed", () => {
    cy.get(":nth-child(1) > .nav-link").click();
    cy.location("pathname").should("equal", "/services");
    cy.get(".btn").should("contain", "Sign In").click();
    cy.origin(Cypress.env("authURL"), () => {
      cy.location("pathname").should("equal", Cypress.env("authRealm"));
      cy.get("#kc-login").click();
      cy.get("#input-error")
        .should("be.visible")
        .and("contain", "Invalid username or password.");
      cy.get('[aria-invalid="true"]').should("have.length", 2); //the 2 input fields should have selector aria-invalid = 'true'
    });
  });
  it("should display login errors when credentials are wrong", () => {
    cy.get(":nth-child(1) > .nav-link").click();
    cy.location("pathname").should("equal", "/services");
    cy.get(".btn").should("contain", "Sign In").click();
    cy.origin(Cypress.env("authURL"), () => {
      cy.location("pathname").should("equal", Cypress.env("authRealm"));

      cy.get("#username").type("test").blur();
      cy.get("#password").type("test").blur();
      cy.get("#kc-login").click();
      cy.get("#input-error")
        .should("be.visible")
        .and("contain", "Invalid username or password.");
      cy.get('[aria-invalid="true"]').should("have.length", 2); //the 2 input fields should have selector aria-invalid = 'true'
    });
  });
  it("should login, logout", () => {
    cy.loginPath(
      ":nth-child(1) > .nav-link",
      "/services"
    );
    cy.get("#navbarDropdown2").click();
    cy.window().then((win) => {
      expect(win.localStorage.getItem("access_token")).to.exist;
    });

    cy.get(
      ":nth-child(2) > .dropdown > .dropdown-menu > :nth-child(8)"
    ).click();
    cy.location("pathname").should("equal", "/");
  });
  it("forget password should work", () => {
    cy.get(":nth-child(1) > .nav-link").click();
    cy.location("pathname").should("equal", "/services");
    cy.get(".btn").should("contain", "Sign In").click();
    cy.origin(Cypress.env("authURL"), () => {
      cy.location("pathname").should("equal", Cypress.env("authRealm"));
      cy.get(":nth-child(2) > span > a").click();
      cy.log(Cypress.env("resetCredentials"));
      cy.location("pathname").should("equal", Cypress.env("resetCredentials"));
      cy.get("#username").should("exist");
    });
  });
  context("register form", () => {
    beforeEach(() => {
      cy.get(":nth-child(1) > .nav-link").click();
      cy.location("pathname").should("equal", "/services");
      cy.get(".btn").should("contain", "Sign In").click();
      cy.origin(Cypress.env("authURL"), () => {
        cy.location("pathname").should("equal", Cypress.env("authRealm"));
        cy.get("#kc-registration > span > a").click();
        cy.location("pathname").should("equal", Cypress.env("registration"));
      });
    });
    it("register form should not be empty when submitted", () => {
      cy.origin(Cypress.env("authURL") + Cypress.env("registration"), () => {
        cy.get(".pf-c-button").click();
        cy.get("#input-error-firstname")
          .should("exist")
          .and("contain", "Please specify first name.");
        cy.get("#input-error-lastname")
          .should("exist")
          .and("contain", "Please specify last name.");
        cy.get("#input-error-email")
          .should("exist")
          .and("contain", "Please specify email.");
        cy.get("#input-error-username")
          .should("exist")
          .and("contain", "Please specify username.");
        cy.get("#input-error-password")
          .should("exist")
          .and("contain", "Please specify password.");
      });
    });
    it("invalid email", () => {
      cy.origin(Cypress.env("authURL") + Cypress.env("registration"), () => {
        cy.get("#email").type("email");
        cy.get(".pf-c-button").click();
        cy.get("#input-error-email")
          .should("exist")
          .and("contain", "Invalid email address.");
        cy.get("#email").type("@example.com");
        cy.get(".pf-c-button").click();
        cy.get("#input-error-email").should("not.exist");
      });
    });
    it("confirm password field should be the same with password", () => {
      cy.origin(Cypress.env("authURL") + Cypress.env("registration"), () => {
        cy.get("#password").type("123");
        cy.get("#password-confirm").type("1234");
        cy.get(".pf-c-button").click();
        cy.get("#input-error-password-confirm")
          .should("exist")
          .and("contain", "Password confirmation doesn't match.");
        cy.get("#password").type("123");
        cy.get("#password-confirm").type("123");
        cy.get(".pf-c-button").click();
        cy.get("#input-error-password-confirm").should("not.exist");
      });
    });
  });
});
Loading