mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat(api): API tokens for authentication
Create and managed simple API tokens for access to the API from external tools.
This commit is contained in:
parent
eda89716ef
commit
8f7eebb806
15 changed files with 614 additions and 154 deletions
|
|
@ -4,6 +4,7 @@ import { JwtService } from "@nestjs/jwt";
|
|||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { User } from "../users/user.entity";
|
||||
import { UsersService } from "../users/users.service";
|
||||
import { ApiTokenRepository } from "./api-token.repository";
|
||||
import { AuthSession } from "./auth-session.entity";
|
||||
import { AuthSessionRepository } from "./auth-session.repository";
|
||||
import { AuthService } from "./auth.service";
|
||||
|
|
@ -15,6 +16,7 @@ describe("AuthService", () => {
|
|||
let usersService: UsersService;
|
||||
let jwtService: JwtService;
|
||||
let authSessionRepository: AuthSessionRepository;
|
||||
let apiTokenRepository: ApiTokenRepository;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
|
|
@ -27,6 +29,7 @@ describe("AuthService", () => {
|
|||
{ provide: UsersService, useFactory: () => ({}) },
|
||||
{ provide: JwtService, useFactory: () => ({}) },
|
||||
{ provide: AuthSessionRepository, useFactory: () => ({}) },
|
||||
{ provide: ApiTokenRepository, useFactory: () => ({}) },
|
||||
],
|
||||
}).compile();
|
||||
|
||||
|
|
@ -37,6 +40,7 @@ describe("AuthService", () => {
|
|||
authSessionRepository = module.get<AuthSessionRepository>(
|
||||
AuthSessionRepository
|
||||
);
|
||||
apiTokenRepository = module.get<ApiTokenRepository>(ApiTokenRepository);
|
||||
});
|
||||
|
||||
it("should be defined", () => {
|
||||
|
|
@ -45,6 +49,7 @@ describe("AuthService", () => {
|
|||
expect(usersService).toBeDefined();
|
||||
expect(jwtService).toBeDefined();
|
||||
expect(authSessionRepository).toBeDefined();
|
||||
expect(apiTokenRepository).toBeDefined();
|
||||
});
|
||||
|
||||
describe("spotifyLogin", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue