jhipster / jhipster-dotnetcore

JHipster.NET blueprint
Apache License 2.0
315 stars 93 forks source link

Incomplete code in Startup.cs for SecurityModule #415

Closed amarflybot closed 4 years ago

amarflybot commented 4 years ago
Overview of the issue

The default vanilla code generated by --blueprints created a compilation issue. Issue found in Startup.cs. for the below code.

public virtual void ConfigureServices(IServiceCollection services)
        {
            services
                .AddNhipsterModule(Configuration);

            AddDatabase(services);

            services
                .AddSecurityModule(jhipsterSettings)
                .AddProblemDetailsModule(Environment)
                .AddAutoMapperModule()
                .AddSwaggerModule()
                .AddWebModule()
                .AddServiceModule();
        }
Reproduce the error

simply installed npm install -g generator-jhipster-dotnetcore and ran jhipster --blueprints dotnetcore

JHipster Version(s)

JHipster.NET v1.1.2

JHipster configuration

Default Config

Screenshot 2020-10-09 at 1 05 19 PM
nicolas63 commented 4 years ago

Can you give me your .yo-rc.json ?

amarflybot commented 4 years ago

.yo-rc.json

{
  "generator-jhipster": {
    "namespace": "sample",
    "databaseType": "postgres",
    "prodDatabaseType": "mysql",
    "jhipsterVersion": "6.10.3",
    "creationTimestamp": 1602226997188,
    "applicationType": "microservice",
    "baseName": "hipsterApp",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [
      {
        "name": "generator-jhipster-dotnetcore",
        "version": "1.1.2"
      }
    ],
    "enableTranslation": false,
    "clientPackageManager": "npm",
    "blueprints": [
      {
        "name": "generator-jhipster-dotnetcore",
        "version": "1.1.2"
      }
    ],
    "skipClient": true,
    "skipUserManagement": true
  }
}
amarflybot commented 4 years ago

I have few more question on the rc file: why is:

"databaseType": "postgres",
    "prodDatabaseType": "mysql",

Is this expected?

nicolas63 commented 4 years ago

I have few more question on the rc file: why is:

"databaseType": "postgres",
    "prodDatabaseType": "mysql",

Is this expected?

yes it's a workaround for jdl importer compatibility but this parameter is never used

https://github.com/jhipster/jhipster-dotnetcore/blob/3f5edbfda96d9f88114c2b4aea79b1e5f7470793/generators/server/index.js#L100

nicolas63 commented 4 years ago

.yo-rc.json

{
  "generator-jhipster": {
    "namespace": "sample",
    "databaseType": "postgres",
    "prodDatabaseType": "mysql",
    "jhipsterVersion": "6.10.3",
    "creationTimestamp": 1602226997188,
    "applicationType": "microservice",
    "baseName": "hipsterApp",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [
      {
        "name": "generator-jhipster-dotnetcore",
        "version": "1.1.2"
      }
    ],
    "enableTranslation": false,
    "clientPackageManager": "npm",
    "blueprints": [
      {
        "name": "generator-jhipster-dotnetcore",
        "version": "1.1.2"
      }
    ],
    "skipClient": true,
    "skipUserManagement": true
  }
}

What is your authentication type ? Did you answer the question about the type of authentication ?

amarflybot commented 4 years ago

I don't think it asked it. Let me try again.

amarflybot commented 4 years ago

Not asking for authentication type.

Screenshot 2020-10-12 at 4 40 59 PM
amarflybot commented 4 years ago

Complete log:

❯ mkdir dotnethipster1
❯ cd dotnethipster1
❯ jhipster --blueprints dotnetcore

INFO! Using JHipster version installed globally
INFO! No custom sharedOptions found within blueprint: generator-jhipster-dotnetcore at /usr/local/lib/node_modules/generator-jhipster-dotnetcore
INFO! No custom commands found within blueprint: generator-jhipster-dotnetcore at /usr/local/lib/node_modules/generator-jhipster-dotnetcore
INFO! Executing jhipster:app
     info Using blueprint generator-jhipster-dotnetcore for app subgenerator

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗    ███╗   ██╗███████╗████████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗   ████╗  ██║██╔════╝╚══██╔══╝
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝   ██╔██╗ ██║█████╗     ██║
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║    ██║╚██╗██║██╔══╝     ██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗██╗██║ ╚████║███████╗   ██║
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝╚═╝╚═╝  ╚═══╝╚══════╝   ╚═╝

                            https://www.jhipster.tech

Welcome to JHipster.NET v1.1.2
Application files will be generated in folder: /Users/amarendrakumar/sandbox/dev-bootcamp/dotnethipster1
 _______________________________________________________________________________________________________________

  Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/
  If you find JHipster useful, consider sponsoring the project at https://opencollective.com/generator-jhipster
 _______________________________________________________________________________________________________________

WARNING! Your Node version is not LTS (Long Term Support), use it at your own risk! JHipster does not support non-LTS releases, so if you encounter a bug, please use a LTS version first.
? Which *type* of application would you like to create? Microservice application
? [Beta] Do you want to make it reactive with Spring WebFlux? No
? What is the base name of your application? sampleApp1
     info Using blueprint generator-jhipster-dotnetcore for server subgenerator
? What is your default C# namespace? sampleapp
? Wchich database do you want to use PostgreSQL
     info Using blueprint generator-jhipster-dotnetcore for common subgenerator
? Would you like to enable internationalization support? No
? Besides JUnit and Jest, which testing frameworks would you like to use?
? Would you like to install other generators from the JHipster Marketplace? No
Git repository initialized.
   create .prettierrc
   create .prettierignore
   create src/SampleApp1/SampleApp1.csproj
   create test/SampleApp1.Test/SampleApp1.Test.csproj
   create src/SampleApp1.Domain/SampleApp1.Domain.csproj
   create src/SampleApp1.Dto/SampleApp1.Dto.csproj
   create src/SampleApp1.Crosscutting/SampleApp1.Crosscutting.csproj
   create src/SampleApp1.Domain.Services/SampleApp1.Domain.Services.csproj
   create src/SampleApp1.Infrastructure/SampleApp1.Infrastructure.csproj
   create src/SampleApp1.Domain/Entities/Interfaces/IAuditedEntityBase.cs
   create src/SampleApp1.Crosscutting/Constants/Constants.cs
   create src/SampleApp1.Crosscutting/Constants/RolesConstants.cs
   create src/SampleApp1.Crosscutting/Constants/ErrorConstants.cs
   create src/SampleApp1.Crosscutting/Exceptions/UsernameNotFoundException.cs
   create src/SampleApp1.Crosscutting/Exceptions/UserNotActivatedException.cs
   create src/SampleApp1.Dto/UserDto.cs
   create src/SampleApp1.Dto/ProfileInfo/ProfileInfoDto.cs
   create src/SampleApp1/Program.cs
   create src/SampleApp1.Infrastructure/Configuration/JHipsterSettings.cs
   create src/SampleApp1/Startup.cs
   create src/SampleApp1/Configuration/AutoMapperStartup.cs
   create src/SampleApp1/Configuration/DatabaseStartup.cs
   create src/SampleApp1/Configuration/MvcStartup.cs
   create src/SampleApp1/Configuration/NhipsterStartup.cs
   create src/SampleApp1/Configuration/ProblemDetailsStartup.cs
   create src/SampleApp1/Configuration/SecurityStartup.cs
   create src/SampleApp1/Configuration/SwaggerStartup.cs
   create src/SampleApp1/Configuration/ServiceStartup.cs
   create src/SampleApp1.Infrastructure/Data/ApplicationDatabaseContext.cs
   create src/SampleApp1/Configuration/AutoMapper/AutoMapperProfile.cs
   create src/SampleApp1/Controllers/AccountController.cs
   create src/SampleApp1/Controllers/ProfileInfoController.cs
   create test/SampleApp1.Test/Controllers/ProfileInfoControllerIntTest.cs
   create src/SampleApp1/Security/PoliciesConstants.cs
   create src/SampleApp1/Web/Extensions/ActionResultExtensions.cs
   create src/SampleApp1/Web/Extensions/ActionResultWithHeaders.cs
   create src/SampleApp1/Web/Extensions/HttpRequestExtensions.cs
   create src/SampleApp1/Web/Filters/ValidateModelAttribute.cs
   create src/SampleApp1/Web/Rest/Utilities/ActionResultUtil.cs
   create src/SampleApp1.Infrastructure/Web/Rest/Utilities/HeaderUtil.cs
   create src/SampleApp1.Infrastructure/Web/Rest/Utilities/PaginationUtil.cs
   create src/SampleApp1.Crosscutting/Exceptions/BaseException.cs
   create src/SampleApp1.Crosscutting/Exceptions/BadRequestAlertException.cs
   create src/SampleApp1.Crosscutting/Exceptions/EmailAlreadyUsedException.cs
   create src/SampleApp1.Crosscutting/Exceptions/EmailNotFoundException.cs
   create src/SampleApp1/Web/Rest/Problems/ExceptionTranslator.cs
   create src/SampleApp1.Crosscutting/Exceptions/InternalServerErrorException.cs
   create src/SampleApp1.Crosscutting/Exceptions/InvalidPasswordException.cs
   create src/SampleApp1.Crosscutting/Exceptions/LoginAlreadyUsedException.cs
   create src/SampleApp1/Web/Rest/Problems/ProblemDetailsConfiguration.cs
   create src/SampleApp1/Web/Rest/Problems/ValidationFailedException.cs
   create test/SampleApp1.Test/Configuration/TestMvcStartup.cs
   create test/SampleApp1.Test/Configuration/MockClaimsPrincipalProvider.cs
   create test/SampleApp1.Test/Setup/MockHttpContextFactory.cs
   create test/SampleApp1.Test/Setup/NhipsterWebApplicationFactory.cs
   create test/SampleApp1.Test/Setup/TestStartup.cs
   create test/SampleApp1.Test/Controllers/TestUtil.cs
   create docker/telegraf/telegraf.conf
   create docker/kapacitor/config/kapacitor.conf
   create docker/influxdb/config/influxdb.conf
   create docker/grafana/data/dashboard/default-dashboard.yaml
   create SonarAnalysis.ps1
   create SonarQube.Analysis.xml
   create .gitattributes
   create .editorconfig
   create src/SampleApp1/Dockerfile
   create .dockerignore
   create .gitignore
    force .yo-rc.json
   create test/SampleApp1.Test/xunit.runner.json
   create src/SampleApp1/Properties/launchSettings.json
   create test/SampleApp1.Test/Properties/launchSettings.json
   create src/SampleApp1/appsettings.json
   create src/SampleApp1/appsettings.Development.json
   create src/SampleApp1/appsettings.Production.json
   create docker/app.yml
   create docker/sonar.yml
   create docker/monitoring.yml
   create docker/grafana/data/dashboard/Docker Monitoring.json
   create docker/grafana/data/provisioning/influxdb.yml
   create README.md
Application successfully committed to Git from /Users/amarendrakumar/sandbox/dev-bootcamp/dotnethipster1.

If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/

Creating SampleApp1 .Net Core solution.

INFO! Congratulations, JHipster execution is complete!
The template "Solution File" was created successfully.
Project `src/SampleApp1/SampleApp1.csproj` added to the solution.
Project `test/SampleApp1.Test/SampleApp1.Test.csproj` added to the solution.
Project `src/SampleApp1.Crosscutting/SampleApp1.Crosscutting.csproj` added to the solution.
Project `src/SampleApp1.Domain/SampleApp1.Domain.csproj` added to the solution.
Project `src/SampleApp1.Dto/SampleApp1.Dto.csproj` added to the solution.
Project `src/SampleApp1.Domain.Services/SampleApp1.Domain.Services.csproj` added to the solution.
Project `src/SampleApp1.Infrastructure/SampleApp1.Infrastructure.csproj` added to the solution.

Server application generated successfully.

Run your .Net Core application:
dotnet run --verbosity normal --project ./src/SampleApp1/SampleApp1.csproj
Test your .Net Core application:
dotnet test --list-tests --verbosity normal
nicolas63 commented 4 years ago

You have choose micro service. Microservice is not available in 1.1.2 . The micro service implementation was added in #413 if you want try it clone and use master. Or you can use monolith architecture who is available in 1.1.2