41 Commits

Author SHA1 Message Date
Sebastian 3466ba8660 Update dependency jsdom to v30
Build Test / test (pull_request) Successful in 32s
JS Unit Tests / test (pull_request) Successful in 28s
PHP Integration Tests / Integration Tests (pull_request) Failing after 1m21s
PHP Unit Tests / test (pull_request) Successful in 3m25s
2026-07-28 03:04:37 +00:00
Sebastian a25569d6f2 refactor: migrate to scoped execution contexts
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-27 00:52:28 -04:00
Sebastian df9fc2b6f5 Merge pull request 'Update dependency vuetify to v4.1.6' (#46) from renovate/vuetify-4.x-lockfile into main
Reviewed-on: #46
2026-07-25 23:50:39 +00:00
Sebastian 267aaa6f87 Update dependency vuetify to v4.1.6
Build Test / test (pull_request) Successful in 1m8s
JS Unit Tests / test (pull_request) Successful in 1m8s
PHP Unit Tests / test (pull_request) Successful in 2m23s
PHP Integration Tests / Integration Tests (pull_request) Successful in 2m29s
2026-07-25 03:05:13 +00:00
Sebastian da1a454515 Merge pull request 'chore: implement js test suites' (#45) from chore/js-test-suites into main
Reviewed-on: #45
2026-07-24 04:32:40 +00:00
Sebastian 471313bf23 chore: implement js test suites
JS Unit Tests / test (pull_request) Successful in 42s
Build Test / test (pull_request) Successful in 45s
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m25s
PHP Unit Tests / test (pull_request) Successful in 1m29s
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-24 00:30:12 -04:00
Sebastian 8774db22ca Merge pull request 'Update dependency pinia to v4' (#40) from renovate/pinia-4.x into main
Reviewed-on: #40
2026-07-24 03:19:04 +00:00
Sebastian 3789235f73 Merge pull request 'Update dependency vuetify to v4.1.6' (#43) from renovate/vuetify-4.x-lockfile into main
Reviewed-on: #43
2026-07-24 03:18:54 +00:00
Sebastian 388066cd31 Update dependency pinia to v4
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m2s
PHP Unit Tests / test (pull_request) Successful in 1m4s
2026-07-24 03:10:14 +00:00
Sebastian 0beb467739 Update dependency vuetify to v4.1.6
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m15s
PHP Unit Tests / test (pull_request) Successful in 1m59s
2026-07-24 03:10:03 +00:00
Sebastian a73f455811 Merge pull request 'Update dependency vue to v3.5.40' (#38) from renovate/vue-monorepo into main
Reviewed-on: #38
2026-07-24 02:36:25 +00:00
Sebastian ec83b1803a Merge pull request 'Update dependency vue-router to v5.2.0' (#39) from renovate/vue-router-5.x-lockfile into main
Reviewed-on: #39
2026-07-24 02:36:17 +00:00
Sebastian c3774ca5ec Merge pull request 'Update dependency vue-tsc to v3.3.8' (#41) from renovate/vue-language-tools-monorepo into main
Reviewed-on: #41
2026-07-24 02:36:01 +00:00
Sebastian 2a9a327f90 Merge pull request 'chore: implement php test suites' (#42) from chore/php83-test-suites into main
Reviewed-on: #42
2026-07-24 02:35:54 +00:00
Sebastian 92646ff218 fix: install module dependencies before running integration tests
PHP Integration Tests / Integration Tests (pull_request) Successful in 1m34s
PHP Unit Tests / test (pull_request) Successful in 1m37s
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-23 22:32:04 -04:00
Sebastian f204a6198c chore: implement php test suites
PHP Integration Tests / Integration Tests (pull_request) Failing after 59s
PHP Unit Tests / test (pull_request) Successful in 2m17s
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-23 22:20:36 -04:00
Sebastian 08069e6f76 Update dependency vue-tsc to v3.3.8 2026-07-23 03:04:06 +00:00
Sebastian 7145c7cad5 Update dependency vue-router to v5.2.0 2026-07-20 03:04:11 +00:00
Sebastian 6d51e9b8f2 Update dependency vue to v3.5.40 2026-07-19 03:04:33 +00:00
Sebastian 5de313b449 fix: remove deprecated baseUrl from module tsconfigs
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-18 21:33:56 -04:00
Sebastian 1ddd49d6d7 fix: login via code
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-18 21:25:51 -04:00
Sebastian 03713df716 Merge pull request 'Update dependency vue-tsc to v3.3.7' (#34) from renovate/vue-language-tools-monorepo into main
Reviewed-on: #34
2026-07-17 23:19:33 +00:00
Sebastian 5738bd6fd4 Merge pull request 'Update dependency typescript to v7' (#35) from renovate/typescript-7.x into main
Reviewed-on: #35
2026-07-17 23:19:26 +00:00
Sebastian 2306fa21d8 Merge pull request 'Update dependency vuetify to v4.1.5' (#36) from renovate/vuetify-4.x-lockfile into main
Reviewed-on: #36
2026-07-17 23:19:18 +00:00
Sebastian 01835ca086 Merge pull request 'Update dependency @vitejs/plugin-vue to v6.0.8' (#37) from renovate/vitejs-plugin-vue-6.x-lockfile into main
Reviewed-on: #37
2026-07-17 23:19:13 +00:00
Sebastian c725574738 Merge pull request 'Update dependency vite to v8.1.5' (#33) from renovate/vite-8.x-lockfile into main
Reviewed-on: #33
2026-07-17 23:19:03 +00:00
Sebastian eecda6c1b0 Update dependency vite to v8.1.5 2026-07-17 03:06:00 +00:00
Sebastian 4486375701 Update dependency @vitejs/plugin-vue to v6.0.8 2026-07-15 03:05:49 +00:00
Sebastian daee835e6d Update dependency vuetify to v4.1.5 2026-07-14 03:06:53 +00:00
Sebastian c62487d4f0 Update dependency typescript to v7 2026-07-11 03:06:01 +00:00
Sebastian d9ca2a92ca Update dependency vue-tsc to v3.3.7 2026-07-10 03:05:43 +00:00
Sebastian 9e20e5178a Track Composer dependencies
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-09 22:56:21 -04:00
Sebastian 1fbc723caf fix(renovate): install renovate in runner temp
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-09 20:12:07 -04:00
Sebastian a1ec501307 Merge pull request 'Update dependency vite to v8.1.3' (#29) from renovate/vite-8.x-lockfile into main
Reviewed-on: #29
2026-07-09 23:49:32 +00:00
Sebastian 3689bfa9bd Merge pull request 'Update dependency vue-tsc to v3.3.6' (#30) from renovate/vue-language-tools-monorepo into main
Reviewed-on: #30
2026-07-09 23:49:24 +00:00
Sebastian 8d251de1d9 Merge pull request 'Update dependency vuetify to v4.1.4' (#32) from renovate/vuetify-4.x-lockfile into main
Reviewed-on: #32
2026-07-09 23:49:19 +00:00
Sebastian 0e5c110af4 Update dependency vuetify to v4.1.4 2026-07-08 03:02:44 +00:00
Sebastian 72ea2edc10 Update dependency vue-tsc to v3.3.6 2026-07-08 03:02:42 +00:00
Sebastian 7c4da104a2 Update dependency vite to v8.1.3 2026-07-08 03:02:39 +00:00
Sebastian 63f1324025 Merge pull request 'Update dependency vuetify to v4.1.3' (#31) from renovate/vuetify-4.x-lockfile into main
Reviewed-on: #31
2026-07-07 22:18:06 +00:00
Sebastian fa6d5b644e Update dependency vuetify to v4.1.3 2026-07-07 03:03:04 +00:00
21 changed files with 3701 additions and 517 deletions
+42
View File
@@ -0,0 +1,42 @@
name: Build Test
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Retrieve Server Install Action
uses: actions/checkout@v6.0.2
with:
repository: Nodarx/action-server-install
ref: main
path: action-server-install
github-server-url: https://git.ktrix.dev
- name: Install Server
uses: ./action-server-install
with:
install-php: 'false'
install-node: 'true'
php-version: '8.5'
node-version: '24'
server-path: './server'
- name: Checkout Pull Request
uses: actions/checkout@v6.0.2
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.sha }}
path: server/modules/authentication_provider_totp
github-server-url: https://git.ktrix.dev
- name: Install dependencies
run: npm ci
working-directory: server/modules/authentication_provider_totp
- name: Build
run: npm run build
working-directory: server/modules/authentication_provider_totp
+42
View File
@@ -0,0 +1,42 @@
name: JS Unit Tests
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Retrieve Server Install Action
uses: actions/checkout@v6.0.2
with:
repository: Nodarx/action-server-install
ref: main
path: action-server-install
github-server-url: https://git.ktrix.dev
- name: Install Server
uses: ./action-server-install
with:
install-php: 'false'
install-node: 'true'
php-version: '8.5'
node-version: '24'
server-path: './server'
- name: Checkout Pull Request
uses: actions/checkout@v6.0.2
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.sha }}
path: server/modules/authentication_provider_totp
github-server-url: https://git.ktrix.dev
- name: Install dependencies
run: npm ci
working-directory: server/modules/authentication_provider_totp
- name: Run tests
run: npm run test:unit
working-directory: server/modules/authentication_provider_totp
@@ -0,0 +1,59 @@
name: PHP Integration Tests
on:
pull_request:
workflow_dispatch:
jobs:
test:
name: Integration Tests
runs-on: ubuntu-latest
services:
mongo:
image: mongo:7
options: >-
--health-cmd "mongosh --quiet --eval \"db.adminCommand('ping')\""
--health-interval 5s
--health-timeout 5s
--health-retries 12
steps:
- name: Retrieve Server Install Action
uses: actions/checkout@v6.0.2
with:
repository: Nodarx/action-server-install
ref: main
path: action-server-install
github-server-url: https://git.ktrix.dev
- name: Install server
uses: ./action-server-install
with:
install-php: 'true'
php-version: '8.5'
server-path: './server'
database-uri: 'mongodb://mongo:27017/?tls=false'
database-name: 'ktrix_ci'
app-environment: 'test'
- name: Checkout module under test
uses: actions/checkout@v6.0.2
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
path: server/modules/authentication_provider_totp
github-server-url: https://git.ktrix.dev
- name: Install module dependencies
run: composer install --prefer-dist --no-progress
working-directory: server/modules/authentication_provider_totp
- name: Install and enable module
working-directory: server
run: |
php bin/console module:install authentication_provider_totp
php bin/console module:enable authentication_provider_totp
- name: Run integration tests
working-directory: server/modules/authentication_provider_totp
run: composer test:integration
+42
View File
@@ -0,0 +1,42 @@
name: PHP Unit Tests
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Retrieve Server Install Action
uses: actions/checkout@v6.0.2
with:
repository: Nodarx/action-server-install
ref: main
path: action-server-install
github-server-url: https://git.ktrix.dev
- name: Install Server
uses: ./action-server-install
with:
install-php: 'true'
install-node: 'false'
php-version: '8.5'
node-version: '24'
server-path: './server'
- name: Checkout Pull Request
uses: actions/checkout@v6.0.2
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.sha }}
path: server/modules/authentication_provider_totp
github-server-url: https://git.ktrix.dev
- name: Install dependencies
run: composer install --prefer-dist --no-progress
working-directory: server/modules/authentication_provider_totp
- name: Run tests
run: composer test:unit
working-directory: server/modules/authentication_provider_totp
+8 -2
View File
@@ -25,11 +25,17 @@ jobs:
tools: composer:v2 tools: composer:v2
- name: Install Renovate - name: Install Renovate
run: npm install -g renovate run: |
npm install --global --no-audit --fund=false \
--prefix "${{ runner.temp }}/renovate-npm" \
--cache "${{ runner.temp }}/renovate-npm-cache" \
renovate
"${{ runner.temp }}/renovate-npm/bin/renovate" --version
- name: Run Renovate - name: Run Renovate
env: env:
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
RENOVATE_PLATFORM: gitea RENOVATE_PLATFORM: gitea
RENOVATE_ENDPOINT: https://git.ktrix.dev/api/v1 RENOVATE_ENDPOINT: https://git.ktrix.dev/api/v1
run: renovate ${{ gitea.repository }} run: |
"${{ runner.temp }}/renovate-npm/bin/renovate" ${{ gitea.repository }}
+2 -4
View File
@@ -12,12 +12,10 @@ node_modules/
/static/ /static/
# Backend development # Backend development
/vendor/
/lib/vendor/ /lib/vendor/
coverage/ coverage/
phpunit.xml.cache *.cache
.phpunit.result.cache
.php-cs-fixer.cache
.phpstan.cache
.phpactor/ .phpactor/
# Editors # Editors
+13 -1
View File
@@ -8,6 +8,18 @@
} }
}, },
"require": { "require": {
"php": ">=8.2" "php": ">=8.3"
},
"require-dev": {
"phpunit/phpunit": "^12.0"
},
"autoload-dev": {
"psr-4": {
"KTXT\\AuthenticationProviderTotp\\Tests\\": "tests/php/"
}
},
"scripts": {
"test:unit": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Unit Tests\" --colors=always --testdox",
"test:integration": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Integration Tests\" --colors=always --testdox"
} }
} }
Generated
+1702
View File
File diff suppressed because it is too large Load Diff
+14 -7
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace KTXM\AuthenticationProviderTotp\Controllers; namespace KTXM\AuthenticationProviderTotp\Controllers;
use KTXC\Http\Response\JsonResponse; use KTXC\Http\Response\JsonResponse;
use KTXC\SessionIdentity; use KTXC\Context\IdentityContextInterface;
use KTXF\Controller\ControllerAbstract; use KTXF\Controller\ControllerAbstract;
use KTXF\Routing\Attributes\AuthenticatedRoute; use KTXF\Routing\Attributes\AuthenticatedRoute;
use KTXM\AuthenticationProviderTotp\Services\EnrollmentService; use KTXM\AuthenticationProviderTotp\Services\EnrollmentService;
@@ -23,7 +23,7 @@ use KTXM\AuthenticationProviderTotp\Services\EnrollmentService;
class EnrollmentController extends ControllerAbstract class EnrollmentController extends ControllerAbstract
{ {
public function __construct( public function __construct(
private readonly SessionIdentity $userIdentity, private readonly IdentityContextInterface $identityContext,
private readonly EnrollmentService $enrollmentService, private readonly EnrollmentService $enrollmentService,
) {} ) {}
@@ -33,7 +33,7 @@ class EnrollmentController extends ControllerAbstract
#[AuthenticatedRoute('/totp/status', name: 'totp.status', methods: ['GET'])] #[AuthenticatedRoute('/totp/status', name: 'totp.status', methods: ['GET'])]
public function status(): JsonResponse public function status(): JsonResponse
{ {
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
if (!$userId) { if (!$userId) {
return new JsonResponse( return new JsonResponse(
['error' => 'User not authenticated', 'error_code' => 'unauthorized'], ['error' => 'User not authenticated', 'error_code' => 'unauthorized'],
@@ -56,7 +56,7 @@ class EnrollmentController extends ControllerAbstract
#[AuthenticatedRoute('/totp/enroll', name: 'totp.enroll.begin', methods: ['POST'])] #[AuthenticatedRoute('/totp/enroll', name: 'totp.enroll.begin', methods: ['POST'])]
public function beginEnrollment(string $accountName = ''): JsonResponse public function beginEnrollment(string $accountName = ''): JsonResponse
{ {
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
if (!$userId) { if (!$userId) {
return new JsonResponse( return new JsonResponse(
['error' => 'User not authenticated', 'error_code' => 'unauthorized'], ['error' => 'User not authenticated', 'error_code' => 'unauthorized'],
@@ -95,7 +95,7 @@ class EnrollmentController extends ControllerAbstract
#[AuthenticatedRoute('/totp/enroll/verify', name: 'totp.enroll.verify', methods: ['POST'])] #[AuthenticatedRoute('/totp/enroll/verify', name: 'totp.enroll.verify', methods: ['POST'])]
public function completeEnrollment(string $code): JsonResponse public function completeEnrollment(string $code): JsonResponse
{ {
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
if (!$userId) { if (!$userId) {
return new JsonResponse( return new JsonResponse(
['error' => 'User not authenticated', 'error_code' => 'unauthorized'], ['error' => 'User not authenticated', 'error_code' => 'unauthorized'],
@@ -128,10 +128,10 @@ class EnrollmentController extends ControllerAbstract
/** /**
* Remove TOTP enrollment (disable 2FA) * Remove TOTP enrollment (disable 2FA)
*/ */
#[AuthenticatedRoute('/totp/enroll', name: 'totp.enroll.remove', methods: ['DELETE'])] #[AuthenticatedRoute('/totp/enroll/remove', name: 'totp.enroll.remove', methods: ['POST'])]
public function removeEnrollment(string $code): JsonResponse public function removeEnrollment(string $code): JsonResponse
{ {
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
if (!$userId) { if (!$userId) {
return new JsonResponse( return new JsonResponse(
['error' => 'User not authenticated', 'error_code' => 'unauthorized'], ['error' => 'User not authenticated', 'error_code' => 'unauthorized'],
@@ -139,6 +139,13 @@ class EnrollmentController extends ControllerAbstract
); );
} }
if (empty($code)) {
return new JsonResponse(
['error' => 'Verification code is required', 'error_code' => 'invalid_request'],
JsonResponse::HTTP_BAD_REQUEST
);
}
// Verify current code before removing // Verify current code before removing
$verifyResult = $this->enrollmentService->verifyCode($userId, $code); $verifyResult = $this->enrollmentService->verifyCode($userId, $code);
if (!$verifyResult['success']) { if (!$verifyResult['success']) {
+9 -9
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace KTXM\AuthenticationProviderTotp\Services; namespace KTXM\AuthenticationProviderTotp\Services;
use KTXC\SessionTenant; use KTXC\Context\TenantContextInterface;
use KTXM\AuthenticationProviderTotp\Stores\EnrollmentStore; use KTXM\AuthenticationProviderTotp\Stores\EnrollmentStore;
/** /**
@@ -26,7 +26,7 @@ class EnrollmentService
private const SECRET_LENGTH = 20; // 160 bits as recommended by RFC 4226 private const SECRET_LENGTH = 20; // 160 bits as recommended by RFC 4226
public function __construct( public function __construct(
private readonly SessionTenant $tenant, private readonly TenantContextInterface $tenantContext,
private readonly EnrollmentStore $enrollmentStore, private readonly EnrollmentStore $enrollmentStore,
) {} ) {}
@@ -35,7 +35,7 @@ class EnrollmentService
*/ */
public function isEnrolled(string $userId): bool public function isEnrolled(string $userId): bool
{ {
$tenantId = $this->tenant->identifier(); $tenantId = $this->tenantContext->identifier();
if (!$tenantId) { if (!$tenantId) {
return false; return false;
} }
@@ -53,7 +53,7 @@ class EnrollmentService
*/ */
public function beginEnrollment(string $userId, array $config = []): array public function beginEnrollment(string $userId, array $config = []): array
{ {
$tenantId = $this->tenant->identifier(); $tenantId = $this->tenantContext->identifier();
if (!$tenantId) { if (!$tenantId) {
return [ return [
'success' => false, 'success' => false,
@@ -108,7 +108,7 @@ class EnrollmentService
*/ */
public function completeEnrollment(string $userId, string $code): array public function completeEnrollment(string $userId, string $code): array
{ {
$tenantId = $this->tenant->identifier(); $tenantId = $this->tenantContext->identifier();
if (!$tenantId) { if (!$tenantId) {
return [ return [
'success' => false, 'success' => false,
@@ -128,7 +128,7 @@ class EnrollmentService
} }
// Verify the code // Verify the code
if (!$this->verifyCode($enrollment['secret'], $code)) { if (!$this->verifyTotpCode($enrollment['secret'], $code)) {
return [ return [
'success' => false, 'success' => false,
'error' => 'Invalid verification code', 'error' => 'Invalid verification code',
@@ -150,7 +150,7 @@ class EnrollmentService
*/ */
public function removeEnrollment(string $userId): array public function removeEnrollment(string $userId): array
{ {
$tenantId = $this->tenant->identifier(); $tenantId = $this->tenantContext->identifier();
if (!$tenantId) { if (!$tenantId) {
return [ return [
'success' => false, 'success' => false,
@@ -181,7 +181,7 @@ class EnrollmentService
*/ */
public function verifyCode(string $userId, string $code): array public function verifyCode(string $userId, string $code): array
{ {
$tenantId = $this->tenant->identifier(); $tenantId = $this->tenantContext->identifier();
if (!$tenantId) { if (!$tenantId) {
return [ return [
'success' => false, 'success' => false,
@@ -225,7 +225,7 @@ class EnrollmentService
*/ */
public function getEnrollmentSecret(string $userId): ?string public function getEnrollmentSecret(string $userId): ?string
{ {
$tenantId = $this->tenant->identifier(); $tenantId = $this->tenantContext->identifier();
if (!$tenantId) { if (!$tenantId) {
return null; return null;
} }
+7 -6
View File
@@ -116,9 +116,9 @@ class EnrollmentStore
} }
/** /**
* Get unused recovery codes for a user * Get unused recovery codes for a user, keyed by their original index
* *
* @return array<string> Unused recovery codes * @return array<int, string> Unused recovery codes
*/ */
public function getRecoveryCodes(string $tenantId, string $userId): array public function getRecoveryCodes(string $tenantId, string $userId): array
{ {
@@ -130,14 +130,15 @@ class EnrollmentStore
$codes = $enrollment['recovery_codes'] ?? []; $codes = $enrollment['recovery_codes'] ?? [];
$usedIndices = $enrollment['used_recovery_codes'] ?? []; $usedIndices = $enrollment['used_recovery_codes'] ?? [];
// Filter out used codes // Filter out used codes, preserving original indices so callers
// can mark the correct code as used
$result = []; $result = [];
foreach ($codes as $index => $code) { foreach ($codes as $index => $code) {
if (!in_array($index, $usedIndices, true)) { if (!in_array($index, $usedIndices, true)) {
$result[] = $code; $result[$index] = $code;
} }
} }
return $result; return $result;
} }
+1567 -482
View File
File diff suppressed because it is too large Load Diff
+11 -3
View File
@@ -11,11 +11,15 @@
"dev": "vite build --mode development --config vite.config.ts", "dev": "vite build --mode development --config vite.config.ts",
"watch": "vite build --mode development --watch --config vite.config.ts", "watch": "vite build --mode development --watch --config vite.config.ts",
"typecheck": "vue-tsc --noEmit", "typecheck": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"test": "vitest run --config tests/js/vitest.config.ts",
"test:unit": "vitest run --config tests/js/vitest.config.ts",
"test:watch": "vitest watch --config tests/js/vitest.config.ts",
"test:coverage": "vitest run --coverage --config tests/js/vitest.config.ts"
}, },
"dependencies": { "dependencies": {
"@mdi/js": "^7.4.47", "@mdi/js": "^7.4.47",
"pinia": "^3.0.0", "pinia": "^4.0.0",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"vue": "^3.5.18", "vue": "^3.5.18",
"vue-router": "^5.0.0", "vue-router": "^5.0.0",
@@ -27,6 +31,10 @@
"@vue/tsconfig": "^0.9.0", "@vue/tsconfig": "^0.9.0",
"typescript": "~6.0.0", "typescript": "~6.0.0",
"vite": "^8.0.0", "vite": "^8.0.0",
"vue-tsc": "^3.0.5" "vue-tsc": "^3.0.5",
"@vitest/coverage-v8": "^4.1.6",
"@vue/test-utils": "^2.4.10",
"jsdom": "^30.0.0",
"vitest": "^4.1.6"
} }
} }
+4 -2
View File
@@ -140,9 +140,11 @@ async function disableTotp() {
disableError.value = '' disableError.value = ''
try { try {
const response = await fetch(`${apiBase}/totp/enroll?code=${encodeURIComponent(disableCode.value)}`, { const response = await fetch(`${apiBase}/totp/enroll/remove`, {
method: 'DELETE', method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include', credentials: 'include',
body: JSON.stringify({ code: disableCode.value }),
}) })
const data = await response.json() const data = await response.json()
+30
View File
@@ -0,0 +1,30 @@
import { describe, it, expect } from 'vitest'
describe('Basic Tests', () => {
it('should perform basic assertion', () => {
expect(true).toBe(true)
})
it('should test array operations', () => {
const array = ['foo', 'bar', 'baz']
expect(array).toHaveLength(3)
expect(array).toContain('bar')
expect(array[0]).toBe('foo')
})
it('should test string operations', () => {
const string = 'Hello, World!'
expect(string).toContain('World')
expect(string.length).toBe(13)
})
it('should test object operations', () => {
const obj = { foo: 'bar', count: 42 }
expect(obj).toHaveProperty('foo')
expect(obj.foo).toBe('bar')
expect(obj.count).toBeGreaterThan(40)
})
})
+33
View File
@@ -0,0 +1,33 @@
import { fileURLToPath } from 'node:url'
import { defineConfig, configDefaults } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import path from 'path'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, '../../src'),
'@KTXC': path.resolve(__dirname, '../../../../core/src'),
},
},
test: {
environment: 'jsdom',
exclude: [...configDefaults.exclude, 'e2e/**'],
root: fileURLToPath(new URL('../../', import.meta.url)),
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'node_modules/',
'tests/',
'**/*.d.ts',
'**/*.config.*',
'**/dist/**',
],
},
},
})
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace KTXT\AuthenticationProviderTotp\Tests\Integration;
use PHPUnit\Framework\TestCase;
class BaseTest extends TestCase
{
public function testBasicAssertion(): void
{
$this->assertTrue(true);
}
public function testArrayOperations(): void
{
$array = ['foo' => 'bar'];
$this->assertArrayHasKey('foo', $array);
$this->assertEquals('bar', $array['foo']);
}
public function testStringOperations(): void
{
$string = 'Hello, World!';
$this->assertStringContainsString('World', $string);
$this->assertEquals(13, strlen($string));
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace KTXT\AuthenticationProviderTotp\Tests\Unit;
use PHPUnit\Framework\TestCase;
class BaseTest extends TestCase
{
public function testBasicAssertion(): void
{
$this->assertTrue(true);
}
public function testArrayOperations(): void
{
$array = ['foo' => 'bar'];
$this->assertArrayHasKey('foo', $array);
$this->assertEquals('bar', $array['foo']);
}
public function testStringOperations(): void
{
$string = 'Hello, World!';
$this->assertStringContainsString('World', $string);
$this->assertEquals(13, strlen($string));
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
require dirname(__DIR__, 2).'/vendor/autoload.php';
// When this module is checked out inside a full server (server/modules/<handle>,
// as it is in CI and in this monorepo checkout), also load the server's own
// core/shared autoloader so tests can reference framework (KTXC/KTXF) types.
// Standalone module checkouts without a server alongside them skip this.
define('SERVER_ROOT', dirname(__DIR__, 4));
$serverAutoload = SERVER_ROOT . '/vendor/autoload.php';
if (is_file($serverAutoload)) {
require $serverAutoload;
}
if (isset($_SERVER['APP_DEBUG']) && $_SERVER['APP_DEBUG']) {
umask(0000);
}
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
failOnDeprecation="true"
failOnNotice="true"
failOnWarning="true"
bootstrap="bootstrap.php"
cacheDirectory="../../.phpunit.cache"
>
<php>
<ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
</php>
<testsuites>
<testsuite name="Unit Tests">
<directory>Unit</directory>
</testsuite>
<testsuite name="Integration Tests">
<directory>Integration</directory>
</testsuite>
</testsuites>
<source ignoreSuppressionOfDeprecations="true"
ignoreIndirectDeprecations="true"
restrictNotices="true"
restrictWarnings="true"
>
<include>
<directory>../../lib</directory>
</include>
</source>
<extensions>
</extensions>
</phpunit>
-1
View File
@@ -6,7 +6,6 @@
"composite": true, "composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"paths": { "paths": {
"@/*": ["./src/*"], "@/*": ["./src/*"],
"@KTXC/*": ["../../core/src/*"] "@KTXC/*": ["../../core/src/*"]