@@ -3,33 +3,35 @@ import "../../src/index.js";
33import { InitCmd , TEMPLATE_DIR } from "@tsed/cli" ;
44import { CliPlatformTest , FakeCliFs } from "@tsed/cli-testing" ;
55
6- describe ( "Init OIDC Provider project" , ( ) => {
7- beforeEach ( ( ) =>
8- CliPlatformTest . bootstrap ( {
9- templateDir : TEMPLATE_DIR ,
10- commands : [ InitCmd ] ,
11- args : [ "init" ]
12- } )
13- ) ;
14- afterEach ( ( ) => CliPlatformTest . reset ( ) ) ;
6+ describe (
7+ "Init OIDC Provider project" ,
8+ ( ) => {
9+ beforeEach ( ( ) =>
10+ CliPlatformTest . bootstrap ( {
11+ templateDir : TEMPLATE_DIR ,
12+ commands : [ InitCmd ] ,
13+ args : [ "init" ]
14+ } )
15+ ) ;
16+ afterEach ( ( ) => CliPlatformTest . reset ( ) ) ;
1517
16- it ( "should generate a project with oidc" , async ( ) => {
17- CliPlatformTest . setPackageJson ( {
18- name : "" ,
19- version : "1.0.0" ,
20- description : "" ,
21- scripts : { } ,
22- dependencies : { } ,
23- devDependencies : { }
24- } ) ;
18+ it ( "should generate a project with oidc" , async ( ) => {
19+ CliPlatformTest . setPackageJson ( {
20+ name : "" ,
21+ version : "1.0.0" ,
22+ description : "" ,
23+ scripts : { } ,
24+ dependencies : { } ,
25+ devDependencies : { }
26+ } ) ;
2527
26- await CliPlatformTest . initProject ( {
27- oidc : true ,
28- testing : true ,
29- oidcBasePath : "/oidc"
30- } ) ;
28+ await CliPlatformTest . initProject ( {
29+ oidc : true ,
30+ testing : true ,
31+ oidcBasePath : "/oidc"
32+ } ) ;
3133
32- expect ( FakeCliFs . getKeys ( ) ) . toMatchInlineSnapshot ( `
34+ expect ( FakeCliFs . getKeys ( ) ) . toMatchInlineSnapshot ( `
3335 [
3436 "project-name",
3537 "project-name/.barrels.json",
@@ -47,56 +49,80 @@ describe("Init OIDC Provider project", () => {
4749 "project-name/src/config/logger/index.ts",
4850 "project-name/src/config/oidc/index.ts",
4951 "project-name/src/config/utils/index.ts",
52+ "project-name/src/controllers/oidc/InteractionsController.spec.ts",
53+ "project-name/src/controllers/oidc/InteractionsController.ts",
5054 "project-name/src/controllers/pages/IndexController.ts",
5155 "project-name/src/controllers/rest/HelloWorldController.ts",
5256 "project-name/src/index.ts",
57+ "project-name/src/interactions/ConsentInteraction.spec.ts",
58+ "project-name/src/interactions/ConsentInteraction.ts",
59+ "project-name/src/interactions/CustomInteraction.ts",
60+ "project-name/src/interactions/LoginInteraction.spec.ts",
61+ "project-name/src/interactions/LoginInteraction.ts",
62+ "project-name/src/interactions/__mock__/oidcContext.fixture.ts",
63+ "project-name/src/models/Account.ts",
64+ "project-name/src/services/Accounts.ts",
5365 "project-name/tsconfig.base.json",
5466 "project-name/tsconfig.json",
5567 "project-name/tsconfig.node.json",
68+ "project-name/views/consent.ejs",
69+ "project-name/views/forms/consent-form.ejs",
70+ "project-name/views/forms/login-form.ejs",
71+ "project-name/views/forms/select-account-form.ejs",
72+ "project-name/views/login.ejs",
73+ "project-name/views/partials/footer.ejs",
74+ "project-name/views/partials/header.ejs",
75+ "project-name/views/partials/login-help.ejs",
76+ "project-name/views/repost.ejs",
77+ "project-name/views/select_account.ejs",
5678 ]
5779 ` ) ;
5880
59- const content = FakeCliFs . files . get ( "project-name/src/Server.ts" ) ! ;
81+ const content = FakeCliFs . files . get ( "project-name/src/Server.ts" ) ! ;
6082
61- expect ( content ) . toContain ( 'import "@tsed/oidc-provider"' ) ;
62- expect ( content ) . toContain ( 'import { InteractionsController } from "./controllers/oidc/InteractionsController.js";' ) ;
63- expect ( content ) . toMatchSnapshot ( ) ;
83+ expect ( content ) . toContain ( 'import "@tsed/oidc-provider"' ) ;
84+ expect ( content ) . toContain ( 'import { InteractionsController } from "./controllers/oidc/InteractionsController.js";' ) ;
85+ expect ( content ) . toMatchSnapshot ( ) ;
6486
65- const configContent = FakeCliFs . files . get ( "project-name/src/config/oidc/index.ts" ) ! ;
87+ const configContent = FakeCliFs . files . get ( "project-name/src/config/oidc/index.ts" ) ! ;
6688
67- expect ( configContent ) . toContain ( 'path: "/oidc"' ) ;
68- } ) ;
69- it ( "should generate a project with oidc and swagger" , async ( ) => {
70- CliPlatformTest . setPackageJson ( {
71- name : "" ,
72- version : "1.0.0" ,
73- description : "" ,
74- scripts : { } ,
75- dependencies : { } ,
76- devDependencies : { }
89+ expect ( configContent ) . toContain ( 'path: "/oidc"' ) ;
7790 } ) ;
91+ it ( "should generate a project with oidc and swagger" , async ( ) => {
92+ CliPlatformTest . setPackageJson ( {
93+ name : "" ,
94+ version : "1.0.0" ,
95+ description : "" ,
96+ scripts : { } ,
97+ dependencies : { } ,
98+ devDependencies : { }
99+ } ) ;
78100
79- await CliPlatformTest . exec ( "init" , {
80- platform : "express" ,
81- rootDir : "./project-data" ,
82- projectName : "project-data" ,
83- tsedVersion : "5.58.1" ,
84- oidc : true ,
85- swagger : true ,
86- route : "/rest" ,
87- oidcBasePath : "/oidc"
88- } ) ;
101+ await CliPlatformTest . exec ( "init" , {
102+ platform : "express" ,
103+ rootDir : "./project-data" ,
104+ projectName : "project-data" ,
105+ tsedVersion : "5.58.1" ,
106+ oidc : true ,
107+ swagger : true ,
108+ route : "/rest" ,
109+ oidcBasePath : "/oidc"
110+ } ) ;
89111
90- expect ( FakeCliFs . getKeys ( ) ) . toMatchSnapshot ( ) ;
112+ expect ( FakeCliFs . getKeys ( ) ) . toMatchSnapshot ( ) ;
91113
92- const content = FakeCliFs . files . get ( "project-name/src/Server.ts" ) ! ;
114+ const content = FakeCliFs . files . get ( "project-name/src/Server.ts" ) ! ;
93115
94- expect ( content ) . toContain ( 'import "@tsed/oidc-provider"' ) ;
95- expect ( content ) . toContain ( 'import { InteractionsController } from "./controllers/oidc/InteractionsController.js";' ) ;
96- expect ( content ) . toMatchSnapshot ( ) ;
116+ expect ( content ) . toContain ( 'import "@tsed/oidc-provider"' ) ;
117+ expect ( content ) . toContain ( 'import { InteractionsController } from "./controllers/oidc/InteractionsController.js";' ) ;
118+ expect ( content ) . toMatchSnapshot ( ) ;
97119
98- const configContent = FakeCliFs . files . get ( "project-name/src/config/oidc/index.ts" ) ! ;
120+ const configContent = FakeCliFs . files . get ( "project-name/src/config/oidc/index.ts" ) ! ;
99121
100- expect ( configContent ) . toContain ( 'path: "/oidc"' ) ;
101- } ) ;
102- } ) ;
122+ expect ( configContent ) . toContain ( 'path: "/oidc"' ) ;
123+ } ) ;
124+ } ,
125+ {
126+ timeout : 15000
127+ }
128+ ) ;
0 commit comments