Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding manual job "Postman collection validations" for dev environment + fix EmailService using ssl config #566

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/postman-collection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Postman collection validations

on:
workflow_dispatch:

jobs:
run-postman-collection-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Postman collection - Development environment
uses: matt-ball/newman-action@master
with:
collection: ShareBook API - Tests.postman_collection.json
delayRequest: 2000
envVar: '[{ "key": "sharebookUrl", "value": "https://dev.sharebook.com.br/" }, { "key": "sharebookEmail", "value": "[email protected]" }, { "key": "sharebookPassword", "value": "123456" }]'
# TODO: Add a job for production environment which must get username and password from github secrets
33 changes: 27 additions & 6 deletions ShareBook API - Tests.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "f7913a70-c6f4-4636-86a3-347efa40216f",
"_postman_id": "4a0b707e-0039-4e40-8fbe-17d85d626c63",
"name": "ShareBook API - Tests",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "29881360"
Expand Down Expand Up @@ -583,7 +583,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n\t\"email\": \"[email protected]\",\r\n\t\"password\": \"123456\"\r\n}",
"raw": "{\r\n\t\"email\": \"{{sharebookEmail}}\",\r\n\t\"password\": \"{{sharebookPassword}}\"\r\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -891,13 +891,34 @@
"type": "text/javascript",
"packages": {},
"exec": [
"\r",
"console.log('Setting up...')\r",
"\r",
"const sharebookUrlName = 'sharebookUrl'\r",
"if (pm.globals.has(sharebookUrlName))\r",
" console.log(`Running using ${pm.globals.get(sharebookUrlName)}`)\r",
"if (pm.environment.has(sharebookUrlName))\r",
" console.log(`Running with ${sharebookUrlName} ${pm.environment.get(sharebookUrlName)}`)\r",
"else {\r",
" const fallbackUrl = 'https://dev.sharebook.com.br/'\r",
" console.log(`The global variable ${sharebookUrlName} isn't found. Using ${fallbackUrl} as default value... `)\r",
" pm.globals.set(sharebookUrlName, fallbackUrl)\r",
" console.log(`The environment variable ${sharebookUrlName} isn't found. Using ${fallbackUrl} as default value... `)\r",
" pm.environment.set(sharebookUrlName, fallbackUrl)\r",
"}\r",
"\r",
"const sharebookEmailName = 'sharebookEmail';\r",
"if (pm.environment.has(sharebookEmailName))\r",
" console.log(`Running with ${sharebookEmailName} : ${pm.environment.get(sharebookEmailName)}`)\r",
"else {\r",
" const fallBackEmail = '[email protected]'\r",
" console.log(`The environment variable ${sharebookEmailName} isn't found. Using ${fallBackEmail} as default value... `)\r",
" pm.environment.set(sharebookEmailName, fallBackEmail)\r",
"}\r",
"\r",
"const sharebookPasswordName = 'sharebookPassword';\r",
"if (pm.environment.has(sharebookPasswordName))\r",
" console.log(`Running with ${sharebookPasswordName} : ${pm.environment.get(sharebookPasswordName)}`)\r",
"else {\r",
" const fallBackPassword = '123456'\r",
" console.log(`The environment variable ${sharebookPasswordName} isn't found. Using ${fallBackPassword} as default value... `)\r",
" pm.environment.set(sharebookPasswordName, fallBackPassword)\r",
"}"
]
}
Expand Down
2 changes: 1 addition & 1 deletion ShareBook/ShareBook.Service/Email/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
InternetAddressList list = new InternetAddressList();
foreach (var admin in admins)
{
list.Add(new MailboxAddress(admin.Email));

Check warning on line 137 in ShareBook/ShareBook.Service/Email/EmailService.cs

View workflow job for this annotation

GitHub Actions / build

'MailboxAddress.MailboxAddress(string)' is obsolete: 'This constructor will be going away due to it causing too much confusion. Use new MailboxAddress(string name, string address) or MailboxAddress.Parse(string) instead.'
}

return list;
Expand All @@ -157,7 +157,7 @@
return log;
}

await _imapClient.ConnectAsync(_settings.HostName, _settings.ImapPort, true);
await _imapClient.ConnectAsync(_settings.HostName, _settings.ImapPort, _settings.UseSSL);
await _imapClient.AuthenticateAsync(_settings.Username, _settings.Password);

var bounceFolder = await GetBounceFolderAsync();
Expand Down Expand Up @@ -194,7 +194,7 @@
return log;
}

private async Task<IMailFolder?> GetBounceFolderAsync()

Check warning on line 197 in ShareBook/ShareBook.Service/Email/EmailService.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
var personal = await _imapClient.GetFolderAsync(_imapClient.PersonalNamespaces[0].Path);
foreach (var folder in await personal.GetSubfoldersAsync(false))
Expand Down
Loading