From cdd1c54dba229476c928de96d7b078e286a449ae Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 31 Jul 2024 22:33:43 +0300 Subject: [PATCH 1/3] feat: README updated --- README.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 19c7d1f8e..2802ba9df 100644 --- a/README.md +++ b/README.md @@ -51,14 +51,7 @@ Front-end part: https://github.com/ita-social-projects/StreetCode_Client ### Environment environmental variables ```properties -spring.datasource.url=${DATASOURCE_URL} -spring.datasource.username=${DATASOURCE_USER} -spring.datasource.password=${DATASOURCE_PASSWORD} -spring.mail.username=${EMAIL_ADDRESS} -spring.mail.password=${EMAIL_PASSWORD} -cloud.name=${CLOUD_NAME} -api.key=${API_KEY} -api.secret=${API_SECRET} +ADMIN_PASSWORD ``` ### Clone @@ -79,10 +72,11 @@ git@github.com:ita-social-projects/StreetCode.git Server={local_server_name};Database=StreetcodeDb;User Id={username};Password={password};MultipleActiveResultSets=true;TrustServerCertificate=true; ``` - **2. Add database seeding** - - Go to `Program.cs` in **StreetCode.WebApi** project and add following code: + **2. Add database seeding and set environment variable** + - Go to `Program.cs` in **StreetCode.WebApi** project and add the following code (replace `{password}` with your password): ```csharp + Environment.SetEnvironmentVariable("ADMIN_PASSWORD", "{password}"); await app.SeedDataAsync(); ``` @@ -110,11 +104,15 @@ git@github.com:ita-social-projects/StreetCode.git 12. Change password to the default system one - **"Admin@1234"**. Don't forget to confirm it afterwards 13. On the left-hand side select **"Status"** page, and set **"Login"** radio-button to **"Enabled"** 14. Click "Ok" +15. Right click on **"localhost"** server on the left-hand side of the UI and click **"Restart"** Now you can connect to your localhost instance with login (sa) and password (Admin@1234)! -**_NOTE:_** Here's the full walkthrough: https://www.youtube.com/watch?v=ANFnDqe4JBk&t=211s. +### Troubleshooting +- If you encounter an unhandled `Microsoft.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)'` while seeding the DB check if you have `TrustServerCertificate=true;` parameter in your connection string and add if you haven't. + +- If you encounter an unhandled `System.IO.DirectoryNotFoundException` while seeding the DB try to specify the absolute paths in `SeedingLocalExtension.cs` to the files in DAL or Streetcode.XIntegrationTest projects. ### How to run Docker From a2a446aac289a64c73a3242d01d38b6dbb21d464 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 1 Aug 2024 09:53:43 +0300 Subject: [PATCH 2/3] feat: fixed syntax error in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2802ba9df..7eb22a2c2 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Now you can connect to your localhost instance with login (sa) and password (Adm ### Troubleshooting -- If you encounter an unhandled `Microsoft.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)'` while seeding the DB check if you have `TrustServerCertificate=true;` parameter in your connection string and add if you haven't. +- If you encounter an unhandled `Microsoft.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)'` while seeding the DB check if you have the `TrustServerCertificate=true;` parameter in your connection string and add it if you don't. - If you encounter an unhandled `System.IO.DirectoryNotFoundException` while seeding the DB try to specify the absolute paths in `SeedingLocalExtension.cs` to the files in DAL or Streetcode.XIntegrationTest projects. From db96a0c812a0cb98d9b18ba91f38cda3d1a9647e Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 2 Aug 2024 22:38:16 +0300 Subject: [PATCH 3/3] feat: specifing paths to the seeding files and setting environment variables changed --- README.md | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7eb22a2c2..24f58ef8a 100644 --- a/README.md +++ b/README.md @@ -72,15 +72,35 @@ git@github.com:ita-social-projects/StreetCode.git Server={local_server_name};Database=StreetcodeDb;User Id={username};Password={password};MultipleActiveResultSets=true;TrustServerCertificate=true; ``` - **2. Add database seeding and set environment variable** - - Go to `Program.cs` in **StreetCode.WebApi** project and add the following code (replace `{password}` with your password): + **2. Set environment variables** + - You can set environment variable before seeding the database in `Program.cs` in **StreetCode.WebApi** project (replace `{password}` with your password): ```csharp Environment.SetEnvironmentVariable("ADMIN_PASSWORD", "{password}"); + ``` + + - Or by specifying in `launchSettings.json` file like: + + ```csharp + { + "profiles": { + "Streetcode_Local": { + "environmentVariables": { + "ADMIN_PASSWORD": "password", + } + } + } + } + ``` + + **3. Add database seeding** + - Go to `Program.cs` in **StreetCode.WebApi** project and add the following code : + + ```csharp await app.SeedDataAsync(); ``` - **3. Create and seed local database** + **4. Create and seed local database** * Run project and make sure that database was created and filled with data ### How to run local @@ -112,7 +132,21 @@ Now you can connect to your localhost instance with login (sa) and password (Adm - If you encounter an unhandled `Microsoft.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)'` while seeding the DB check if you have the `TrustServerCertificate=true;` parameter in your connection string and add it if you don't. -- If you encounter an unhandled `System.IO.DirectoryNotFoundException` while seeding the DB try to specify the absolute paths in `SeedingLocalExtension.cs` to the files in DAL or Streetcode.XIntegrationTest projects. +- If you encounter an unhandled `System.IO.DirectoryNotFoundException` while seeding the DB try to specify relative paths in `SeedingLocalExtension.cs` to `images.json` and `audios.json` in DAL or Streetcode.XIntegrationTest projects like: + + ```text + ../Streetcode.DAL/InitialData/images.json + ../Streetcode.DAL/InitialData/audios.json + ``` + + or + + ```text + ../Streetcode.XIntegrationTest/TestData/InitialData/images.json + ../Streetcode.XIntegrationTest/TestData/InitialData/audios.json + ``` + + If exception is still present specify the absolute paths. ### How to run Docker