From d8ff186303b605e0e0e3da2b59fe1978c2c823fa Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Sat, 7 Oct 2017 00:09:42 +0200 Subject: [PATCH] Split client and server Client and server now have their own tsconfig so that the transpilation is only done on the part that is being modified. It also allows faster transpilation since tests are now excluded from tsconfig. They are compiled by ts-node during unit tests execution. --- .gitignore | 2 + Dockerfile | 5 +- Gruntfile.js | 111 +++++++++++------- .../src}/css/00-bootstrap.min.css | 0 {src/client => client/src}/css/01-main.css | 0 {src/client => client/src}/css/02-login.css | 0 {src/client => client/src}/css/03-errors.css | 0 .../src}/css/03-password-reset-form.css | 0 .../src}/css/03-password-reset-request.css | 0 .../src}/css/03-totp-register.css | 0 .../src}/css/03-u2f-register.css | 0 {src/client => client/src}/img/icon.png | Bin {src/client => client/src}/img/mail.png | Bin {src/client => client/src}/img/padlock.png | Bin {src/client => client/src}/img/password.png | Bin {src/client => client/src}/img/pendrive.png | Bin {src/client => client/src}/img/success.png | Bin {src/client => client/src}/img/user.png | Bin {src/client => client/src}/img/warning.png | Bin {src/client => client/src}/index.ts | 4 +- {src/client => client/src}/lib/INotifier.ts | 0 {src/client => client/src}/lib/Notifier.ts | 0 .../src}/lib/QueryParametersRetriever.ts | 0 .../lib/firstfactor/FirstFactorValidator.ts | 4 +- .../src}/lib/firstfactor/UISelectors.ts | 0 .../src}/lib/firstfactor/index.ts | 4 +- .../src}/lib/reset-password/constants.ts | 0 .../lib/reset-password/reset-password-form.ts | 2 +- .../reset-password/reset-password-request.ts | 2 +- .../src}/lib/secondfactor/TOTPValidator.ts | 2 +- .../src}/lib/secondfactor/U2FValidator.ts | 4 +- .../src}/lib/secondfactor/constants.ts | 0 .../src}/lib/secondfactor/index.ts | 4 +- .../src}/lib/totp-register/totp-register.ts | 0 .../src}/lib/totp-register/ui-selector.ts | 0 .../src}/lib/u2f-register/u2f-register.ts | 2 +- .../src}/thirdparties/qrcode.min.js | 0 .../client => client/test}/Notifier.test.ts | 2 +- .../firstfactor/FirstFactorValidator.test.ts | 2 +- .../test}/mocks/NotifierStub.ts | 2 +- .../client => client/test}/mocks/jquery.ts | 0 .../client => client/test}/mocks/u2f-api.ts | 0 .../test}/secondfactor/TOTPValidator.test.ts | 2 +- .../test}/secondfactor/U2FValidator.test.ts | 6 +- .../test}/totp-register/totp-register.test.ts | 4 +- tsconfig.json => client/tsconfig.json | 12 +- tslint.json => client/tslint.json | 0 {src => client}/types/u2f-api.d.ts | 0 docker-compose.dev.yml | 3 +- package.json | 3 +- scripts/integration-tests.sh | 9 +- scripts/travis.sh | 2 +- {src/server => server/src}/index.ts | 0 .../src}/lib/AuthenticationRegulator.ts | 0 .../src}/lib/AuthenticationSession.ts | 0 .../src}/lib/AuthenticationValidator.ts | 0 .../server => server/src}/lib/ErrorReplies.ts | 0 {src/server => server/src}/lib/Exceptions.ts | 0 .../src}/lib/FirstFactorValidator.ts | 0 .../src}/lib/IdentityCheckMiddleware.ts | 0 .../lib/IdentityCheckPreValidationTemplate.ts | 0 {src/server => server/src}/lib/RestApi.ts | 2 +- {src/server => server/src}/lib/Server.ts | 0 .../src}/lib/ServerVariablesHandler.ts | 0 .../src}/lib/TOTPGenerator.ts | 0 .../src}/lib/TOTPValidator.ts | 0 .../lib/access_control/AccessController.ts | 0 .../src}/lib/access_control/DomainMatcher.ts | 0 .../lib/access_control/IAccessController.ts | 0 .../src}/lib/configuration/Configuration.d.ts | 0 .../lib/configuration/ConfigurationAdapter.ts | 0 .../SessionConfigurationBuilder.ts | 0 .../lib/connectors/mongo/IMongoClient.d.ts | 0 .../lib/connectors/mongo/IMongoConnector.d.ts | 0 .../mongo/IMongoConnectorFactory.d.ts | 0 .../src}/lib/connectors/mongo/MongoClient.ts | 0 .../lib/connectors/mongo/MongoConnector.ts | 0 .../connectors/mongo/MongoConnectorFactory.ts | 0 .../src}/lib/ldap/Authenticator.ts | 0 {src/server => server/src}/lib/ldap/Client.ts | 10 ++ .../src}/lib/ldap/ClientFactory.ts | 0 .../src}/lib/ldap/EmailsRetriever.ts | 0 .../src}/lib/ldap/IAuthenticator.ts | 0 .../server => server/src}/lib/ldap/IClient.ts | 0 .../src}/lib/ldap/IClientFactory.ts | 0 .../src}/lib/ldap/IEmailsRetriever.ts | 0 .../src}/lib/ldap/IPasswordUpdater.ts | 0 .../src}/lib/ldap/PasswordUpdater.ts | 0 .../lib/notifiers/AbstractEmailNotifier.ts | 0 .../src}/lib/notifiers/GMailNotifier.ts | 0 .../src}/lib/notifiers/INotifier.d.ts | 0 .../src}/lib/notifiers/NotifierFactory.ts | 0 .../src}/lib/notifiers/SmtpNotifier.ts | 0 .../src}/lib/routes/FirstFactorBlocker.ts | 0 .../src}/lib/routes/error/401/get.ts | 0 .../src}/lib/routes/error/403/get.ts | 0 .../src}/lib/routes/error/404/get.ts | 0 .../src}/lib/routes/firstfactor/get.ts | 2 +- .../src}/lib/routes/firstfactor/post.ts | 4 +- .../src}/lib/routes/logout/get.ts | 0 .../lib/routes/password-reset/constants.ts | 0 .../lib/routes/password-reset/form/post.ts | 0 .../identity/PasswordResetHandler.ts | 0 .../lib/routes/password-reset/request/get.ts | 0 .../src}/lib/routes/secondfactor/get.ts | 2 +- .../src}/lib/routes/secondfactor/redirect.ts | 2 +- .../lib/routes/secondfactor/totp/constants.ts | 0 .../totp/identity/RegistrationHandler.ts | 2 +- .../lib/routes/secondfactor/totp/sign/post.ts | 2 +- .../lib/routes/secondfactor/u2f/U2FCommon.ts | 0 .../u2f/identity/RegistrationHandler.ts | 0 .../routes/secondfactor/u2f/register/post.ts | 0 .../secondfactor/u2f/register_request/get.ts | 0 .../lib/routes/secondfactor/u2f/sign/post.ts | 0 .../secondfactor/u2f/sign_request/get.ts | 2 +- .../src}/lib/routes/verify/get.ts | 2 +- .../storage/AuthenticationTraceDocument.d.ts | 0 .../lib/storage/CollectionFactoryFactory.ts | 0 .../src}/lib/storage/ICollection.d.ts | 0 .../src}/lib/storage/ICollectionFactory.d.ts | 0 .../src}/lib/storage/IUserDataStore.d.ts | 0 .../storage/IdentityValidationDocument.d.ts | 0 .../src}/lib/storage/TOTPSecretDocument.d.ts | 0 .../lib/storage/U2FRegistrationDocument.d.ts | 0 .../src}/lib/storage/UserDataStore.ts | 0 .../src}/lib/storage/mongo/MongoCollection.ts | 0 .../storage/mongo/MongoCollectionFactory.ts | 0 .../src}/lib/storage/nedb/NedbCollection.ts | 15 ++- .../lib/storage/nedb/NedbCollectionFactory.ts | 0 .../src}/resources/email-template.ejs | 0 .../src}/views/already-logged-in.pug | 0 .../src}/views/errors/401.pug | 0 .../src}/views/errors/403.pug | 0 .../src}/views/errors/404.pug | 0 .../src}/views/firstfactor.pug | 0 .../src}/views/layout/layout.pug | 0 .../src}/views/need-identity-validation.pug | 0 .../src}/views/password-reset-form.pug | 0 .../src}/views/password-reset-request.pug | 0 .../src}/views/secondfactor.pug | 0 .../src}/views/totp-register.pug | 0 .../src}/views/u2f-register.pug | 0 .../test}/AuthenticationRegulator.test.ts | 4 +- .../test}/IdentityCheckMiddleware.test.ts | 8 +- .../test}/ServerConfiguration.test.ts | 6 +- .../test}/SessionConfigurationBuilder.test.ts | 6 +- .../test}/TOTPValidator.test.ts | 2 +- .../access_control/AccessController.test.ts | 4 +- .../ConfigurationAdapter.test.ts | 4 +- .../LdapConfigurationAdaptation.test.ts | 4 +- .../connectors/mongo/MongoClient.test.ts | 2 +- .../connectors/mongo/MongoConnector.test.ts | 4 +- .../mongo/MongoConnectorFactory.test.ts | 2 +- .../test}/ldap/Authenticator.test.ts | 4 +- .../test}/ldap/EmailsRetriever.test.ts | 4 +- .../test}/ldap/PasswordUpdater.test.ts | 4 +- .../test}/mocks/AccessControllerStub.ts | 2 +- .../test}/mocks/AuthenticationRegulator.ts | 0 .../test}/mocks/IdentityValidator.ts | 4 +- .../server => server/test}/mocks/Notifier.ts | 0 .../test}/mocks/ServerVariablesMock.ts | 2 +- .../test}/mocks/TOTPValidator.ts | 0 .../mocks/connectors/mongo/MongoClientStub.ts | 2 +- .../server => server/test}/mocks/express.ts | 0 .../test}/mocks/ldap/ClientFactoryStub.ts | 4 +- .../test}/mocks/ldap/ClientStub.ts | 2 +- .../server => server/test}/mocks/ldapjs.ts | 0 .../test}/mocks/nodemailer.ts | 0 .../server => server/test}/mocks/speakeasy.ts | 0 .../mocks/storage/CollectionFactoryStub.ts | 4 +- .../test}/mocks/storage/CollectionStub.ts | 2 +- .../test}/mocks/storage/UserDataStoreStub.ts | 14 +-- .../unit/server => server/test}/mocks/u2f.ts | 0 .../test}/notifiers/GMailNotifier.test.ts | 2 +- .../test}/notifiers/NotifierFactory.test.ts | 6 +- {test/unit/server => server/test}/requests.ts | 16 ++- .../test}/routes/errors/401/get.test.ts | 2 +- .../test}/routes/errors/403/get.test.ts | 2 +- .../test}/routes/errors/404/get.test.ts | 2 +- .../test}/routes/firstfactor/post.test.ts | 10 +- .../identity/PasswordResetHandler.test.ts | 8 +- .../test}/routes/password-reset/post.test.ts | 10 +- .../totp/register/RegistrationHandler.test.ts | 8 +- .../secondfactor/totp/sign/post.test.ts | 6 +- .../u2f/identity/RegistrationHandler.test.ts | 6 +- .../secondfactor/u2f/register/post.test.ts | 6 +- .../u2f/register_request/get.test.ts | 6 +- .../routes/secondfactor/u2f/sign/post.test.ts | 6 +- .../secondfactor/u2f/sign_request/get.test.ts | 8 +- .../test}/routes/verify/get.test.ts | 4 +- .../test}/server/PrivatePages.ts | 10 +- .../test}/server/PublicPages.ts | 10 +- .../test}/storage/UserDataStore.test.ts | 8 +- .../storage/mongo/MongoCollection.test.ts | 2 +- .../mongo/MongoCollectionFactory.test.ts | 2 +- .../test}/storage/nedb/NedbCollection.test.ts | 2 +- .../nedb/NedbCollectionFactory.test.ts | 2 +- server/tsconfig.json | 24 ++++ server/tslint.json | 60 ++++++++++ {src => server}/types/Dependencies.ts | 0 {src => server}/types/Identity.ts | 0 {src => server}/types/TOTPSecret.ts | 0 {src => server}/types/U2FRegistration.ts | 0 {src => server}/types/dovehash.d.ts | 0 .../sign_request => shared}/SignMessage.ts | 1 - src/server/endpoints.ts => shared/api.ts | 0 {src/server => shared}/constants.ts | 0 {src => shared}/types/u2f.d.ts | 0 src/types/ldapjs-async.d.ts | 13 -- src/types/nedb-async.d.ts | 13 -- src/types/request-async.d.ts | 15 --- test/features/access-control.feature | 9 +- .../step_definitions/authentication.ts | 5 +- test/features/step_definitions/hooks.ts | 10 +- 214 files changed, 370 insertions(+), 256 deletions(-) rename {src/client => client/src}/css/00-bootstrap.min.css (100%) rename {src/client => client/src}/css/01-main.css (100%) rename {src/client => client/src}/css/02-login.css (100%) rename {src/client => client/src}/css/03-errors.css (100%) rename {src/client => client/src}/css/03-password-reset-form.css (100%) rename {src/client => client/src}/css/03-password-reset-request.css (100%) rename {src/client => client/src}/css/03-totp-register.css (100%) rename {src/client => client/src}/css/03-u2f-register.css (100%) rename {src/client => client/src}/img/icon.png (100%) rename {src/client => client/src}/img/mail.png (100%) rename {src/client => client/src}/img/padlock.png (100%) rename {src/client => client/src}/img/password.png (100%) rename {src/client => client/src}/img/pendrive.png (100%) rename {src/client => client/src}/img/success.png (100%) rename {src/client => client/src}/img/user.png (100%) rename {src/client => client/src}/img/warning.png (100%) rename {src/client => client/src}/index.ts (92%) rename {src/client => client/src}/lib/INotifier.ts (100%) rename {src/client => client/src}/lib/Notifier.ts (100%) rename {src/client => client/src}/lib/QueryParametersRetriever.ts (100%) rename {src/client => client/src}/lib/firstfactor/FirstFactorValidator.ts (87%) rename {src/client => client/src}/lib/firstfactor/UISelectors.ts (100%) rename {src/client => client/src}/lib/firstfactor/index.ts (92%) rename {src/client => client/src}/lib/reset-password/constants.ts (100%) rename {src/client => client/src}/lib/reset-password/reset-password-form.ts (96%) rename {src/client => client/src}/lib/reset-password/reset-password-request.ts (96%) rename {src/client => client/src}/lib/secondfactor/TOTPValidator.ts (91%) rename {src/client => client/src}/lib/secondfactor/U2FValidator.ts (93%) rename {src/client => client/src}/lib/secondfactor/constants.ts (100%) rename {src/client => client/src}/lib/secondfactor/index.ts (94%) rename {src/client => client/src}/lib/totp-register/totp-register.ts (100%) rename {src/client => client/src}/lib/totp-register/ui-selector.ts (100%) rename {src/client => client/src}/lib/u2f-register/u2f-register.ts (97%) rename {src/client => client/src}/thirdparties/qrcode.min.js (100%) rename {test/unit/client => client/test}/Notifier.test.ts (96%) rename {test/unit/client => client/test}/firstfactor/FirstFactorValidator.test.ts (94%) rename {test/unit/client => client/test}/mocks/NotifierStub.ts (89%) rename {test/unit/client => client/test}/mocks/jquery.ts (100%) rename {test/unit/client => client/test}/mocks/u2f-api.ts (100%) rename {test/unit/client => client/test}/secondfactor/TOTPValidator.test.ts (93%) rename {test/unit/client => client/test}/secondfactor/U2FValidator.test.ts (94%) rename {test/unit/client => client/test}/totp-register/totp-register.test.ts (79%) rename tsconfig.json => client/tsconfig.json (68%) rename tslint.json => client/tslint.json (100%) rename {src => client}/types/u2f-api.d.ts (100%) rename {src/server => server/src}/index.ts (100%) rename {src/server => server/src}/lib/AuthenticationRegulator.ts (100%) rename {src/server => server/src}/lib/AuthenticationSession.ts (100%) rename {src/server => server/src}/lib/AuthenticationValidator.ts (100%) rename {src/server => server/src}/lib/ErrorReplies.ts (100%) rename {src/server => server/src}/lib/Exceptions.ts (100%) rename {src/server => server/src}/lib/FirstFactorValidator.ts (100%) rename {src/server => server/src}/lib/IdentityCheckMiddleware.ts (100%) rename {src/server => server/src}/lib/IdentityCheckPreValidationTemplate.ts (100%) rename {src/server => server/src}/lib/RestApi.ts (98%) rename {src/server => server/src}/lib/Server.ts (100%) rename {src/server => server/src}/lib/ServerVariablesHandler.ts (100%) rename {src/server => server/src}/lib/TOTPGenerator.ts (100%) rename {src/server => server/src}/lib/TOTPValidator.ts (100%) rename {src/server => server/src}/lib/access_control/AccessController.ts (100%) rename {src/server => server/src}/lib/access_control/DomainMatcher.ts (100%) rename {src/server => server/src}/lib/access_control/IAccessController.ts (100%) rename {src/server => server/src}/lib/configuration/Configuration.d.ts (100%) rename {src/server => server/src}/lib/configuration/ConfigurationAdapter.ts (100%) rename {src/server => server/src}/lib/configuration/SessionConfigurationBuilder.ts (100%) rename {src/server => server/src}/lib/connectors/mongo/IMongoClient.d.ts (100%) rename {src/server => server/src}/lib/connectors/mongo/IMongoConnector.d.ts (100%) rename {src/server => server/src}/lib/connectors/mongo/IMongoConnectorFactory.d.ts (100%) rename {src/server => server/src}/lib/connectors/mongo/MongoClient.ts (100%) rename {src/server => server/src}/lib/connectors/mongo/MongoConnector.ts (100%) rename {src/server => server/src}/lib/connectors/mongo/MongoConnectorFactory.ts (100%) rename {src/server => server/src}/lib/ldap/Authenticator.ts (100%) rename {src/server => server/src}/lib/ldap/Client.ts (93%) rename {src/server => server/src}/lib/ldap/ClientFactory.ts (100%) rename {src/server => server/src}/lib/ldap/EmailsRetriever.ts (100%) rename {src/server => server/src}/lib/ldap/IAuthenticator.ts (100%) rename {src/server => server/src}/lib/ldap/IClient.ts (100%) rename {src/server => server/src}/lib/ldap/IClientFactory.ts (100%) rename {src/server => server/src}/lib/ldap/IEmailsRetriever.ts (100%) rename {src/server => server/src}/lib/ldap/IPasswordUpdater.ts (100%) rename {src/server => server/src}/lib/ldap/PasswordUpdater.ts (100%) rename {src/server => server/src}/lib/notifiers/AbstractEmailNotifier.ts (100%) rename {src/server => server/src}/lib/notifiers/GMailNotifier.ts (100%) rename {src/server => server/src}/lib/notifiers/INotifier.d.ts (100%) rename {src/server => server/src}/lib/notifiers/NotifierFactory.ts (100%) rename {src/server => server/src}/lib/notifiers/SmtpNotifier.ts (100%) rename {src/server => server/src}/lib/routes/FirstFactorBlocker.ts (100%) rename {src/server => server/src}/lib/routes/error/401/get.ts (100%) rename {src/server => server/src}/lib/routes/error/403/get.ts (100%) rename {src/server => server/src}/lib/routes/error/404/get.ts (100%) rename {src/server => server/src}/lib/routes/firstfactor/get.ts (92%) rename {src/server => server/src}/lib/routes/firstfactor/post.ts (97%) rename {src/server => server/src}/lib/routes/logout/get.ts (100%) rename {src/server => server/src}/lib/routes/password-reset/constants.ts (100%) rename {src/server => server/src}/lib/routes/password-reset/form/post.ts (100%) rename {src/server => server/src}/lib/routes/password-reset/identity/PasswordResetHandler.ts (100%) rename {src/server => server/src}/lib/routes/password-reset/request/get.ts (100%) rename {src/server => server/src}/lib/routes/secondfactor/get.ts (93%) rename {src/server => server/src}/lib/routes/secondfactor/redirect.ts (92%) rename {src/server => server/src}/lib/routes/secondfactor/totp/constants.ts (100%) rename {src/server => server/src}/lib/routes/secondfactor/totp/identity/RegistrationHandler.ts (98%) rename {src/server => server/src}/lib/routes/secondfactor/totp/sign/post.ts (96%) rename {src/server => server/src}/lib/routes/secondfactor/u2f/U2FCommon.ts (100%) rename {src/server => server/src}/lib/routes/secondfactor/u2f/identity/RegistrationHandler.ts (100%) rename {src/server => server/src}/lib/routes/secondfactor/u2f/register/post.ts (100%) rename {src/server => server/src}/lib/routes/secondfactor/u2f/register_request/get.ts (100%) rename {src/server => server/src}/lib/routes/secondfactor/u2f/sign/post.ts (100%) rename {src/server => server/src}/lib/routes/secondfactor/u2f/sign_request/get.ts (97%) rename {src/server => server/src}/lib/routes/verify/get.ts (97%) rename {src/server => server/src}/lib/storage/AuthenticationTraceDocument.d.ts (100%) rename {src/server => server/src}/lib/storage/CollectionFactoryFactory.ts (100%) rename {src/server => server/src}/lib/storage/ICollection.d.ts (100%) rename {src/server => server/src}/lib/storage/ICollectionFactory.d.ts (100%) rename {src/server => server/src}/lib/storage/IUserDataStore.d.ts (100%) rename {src/server => server/src}/lib/storage/IdentityValidationDocument.d.ts (100%) rename {src/server => server/src}/lib/storage/TOTPSecretDocument.d.ts (100%) rename {src/server => server/src}/lib/storage/U2FRegistrationDocument.d.ts (100%) rename {src/server => server/src}/lib/storage/UserDataStore.ts (100%) rename {src/server => server/src}/lib/storage/mongo/MongoCollection.ts (100%) rename {src/server => server/src}/lib/storage/mongo/MongoCollectionFactory.ts (100%) rename {src/server => server/src}/lib/storage/nedb/NedbCollection.ts (66%) rename {src/server => server/src}/lib/storage/nedb/NedbCollectionFactory.ts (100%) rename {src/server => server/src}/resources/email-template.ejs (100%) rename {src/server => server/src}/views/already-logged-in.pug (100%) rename {src/server => server/src}/views/errors/401.pug (100%) rename {src/server => server/src}/views/errors/403.pug (100%) rename {src/server => server/src}/views/errors/404.pug (100%) rename {src/server => server/src}/views/firstfactor.pug (100%) rename {src/server => server/src}/views/layout/layout.pug (100%) rename {src/server => server/src}/views/need-identity-validation.pug (100%) rename {src/server => server/src}/views/password-reset-form.pug (100%) rename {src/server => server/src}/views/password-reset-request.pug (100%) rename {src/server => server/src}/views/secondfactor.pug (100%) rename {src/server => server/src}/views/totp-register.pug (100%) rename {src/server => server/src}/views/u2f-register.pug (100%) rename {test/unit/server => server/test}/AuthenticationRegulator.test.ts (97%) rename {test/unit/server => server/test}/IdentityCheckMiddleware.test.ts (95%) rename {test/unit/server => server/test}/ServerConfiguration.test.ts (89%) rename {test/unit/server => server/test}/SessionConfigurationBuilder.test.ts (94%) rename {test/unit/server => server/test}/TOTPValidator.test.ts (91%) rename {test/unit/server => server/test}/access_control/AccessController.test.ts (98%) rename {test/unit/server => server/test}/configuration/ConfigurationAdapter.test.ts (94%) rename {test/unit/server => server/test}/configuration/LdapConfigurationAdaptation.test.ts (92%) rename {test/unit/server => server/test}/connectors/mongo/MongoClient.test.ts (92%) rename {test/unit/server => server/test}/connectors/mongo/MongoConnector.test.ts (88%) rename {test/unit/server => server/test}/connectors/mongo/MongoConnectorFactory.test.ts (74%) rename {test/unit/server => server/test}/ldap/Authenticator.test.ts (96%) rename {test/unit/server => server/test}/ldap/EmailsRetriever.test.ts (93%) rename {test/unit/server => server/test}/ldap/PasswordUpdater.test.ts (93%) rename {test/unit/server => server/test}/mocks/AccessControllerStub.ts (79%) rename {test/unit/server => server/test}/mocks/AuthenticationRegulator.ts (100%) rename {test/unit/server => server/test}/mocks/IdentityValidator.ts (86%) rename {test/unit/server => server/test}/mocks/Notifier.ts (100%) rename {test/unit/server => server/test}/mocks/ServerVariablesMock.ts (92%) rename {test/unit/server => server/test}/mocks/TOTPValidator.ts (100%) rename {test/unit/server => server/test}/mocks/connectors/mongo/MongoClientStub.ts (77%) rename {test/unit/server => server/test}/mocks/express.ts (100%) rename {test/unit/server => server/test}/mocks/ldap/ClientFactoryStub.ts (65%) rename {test/unit/server => server/test}/mocks/ldap/ClientStub.ts (93%) rename {test/unit/server => server/test}/mocks/ldapjs.ts (100%) rename {test/unit/server => server/test}/mocks/nodemailer.ts (100%) rename {test/unit/server => server/test}/mocks/speakeasy.ts (100%) rename {test/unit/server => server/test}/mocks/storage/CollectionFactoryStub.ts (66%) rename {test/unit/server => server/test}/mocks/storage/CollectionStub.ts (93%) rename {test/unit/server => server/test}/mocks/storage/UserDataStoreStub.ts (79%) rename {test/unit/server => server/test}/mocks/u2f.ts (100%) rename {test/unit/server => server/test}/notifiers/GMailNotifier.test.ts (93%) rename {test/unit/server => server/test}/notifiers/NotifierFactory.test.ts (82%) rename {test/unit/server => server/test}/requests.ts (89%) rename {test/unit/server => server/test}/routes/errors/401/get.test.ts (85%) rename {test/unit/server => server/test}/routes/errors/403/get.test.ts (85%) rename {test/unit/server => server/test}/routes/errors/404/get.test.ts (85%) rename {test/unit/server => server/test}/routes/firstfactor/post.test.ts (92%) rename {test/unit/server => server/test}/routes/password-reset/identity/PasswordResetHandler.test.ts (90%) rename {test/unit/server => server/test}/routes/password-reset/post.test.ts (89%) rename {test/unit/server => server/test}/routes/secondfactor/totp/register/RegistrationHandler.test.ts (88%) rename {test/unit/server => server/test}/routes/secondfactor/totp/sign/post.test.ts (91%) rename {test/unit/server => server/test}/routes/secondfactor/u2f/identity/RegistrationHandler.test.ts (91%) rename {test/unit/server => server/test}/routes/secondfactor/u2f/register/post.test.ts (94%) rename {test/unit/server => server/test}/routes/secondfactor/u2f/register_request/get.test.ts (90%) rename {test/unit/server => server/test}/routes/secondfactor/u2f/sign/post.test.ts (90%) rename {test/unit/server => server/test}/routes/secondfactor/u2f/sign_request/get.test.ts (84%) rename {test/unit/server => server/test}/routes/verify/get.test.ts (97%) rename {test/unit/server => server/test}/server/PrivatePages.ts (94%) rename {test/unit/server => server/test}/server/PublicPages.ts (92%) rename {test/unit/server => server/test}/storage/UserDataStore.test.ts (96%) rename {test/unit/server => server/test}/storage/mongo/MongoCollection.test.ts (97%) rename {test/unit/server => server/test}/storage/mongo/MongoCollectionFactory.test.ts (83%) rename {test/unit/server => server/test}/storage/nedb/NedbCollection.test.ts (97%) rename {test/unit/server => server/test}/storage/nedb/NedbCollectionFactory.test.ts (77%) create mode 100644 server/tsconfig.json create mode 100644 server/tslint.json rename {src => server}/types/Dependencies.ts (100%) rename {src => server}/types/Identity.ts (100%) rename {src => server}/types/TOTPSecret.ts (100%) rename {src => server}/types/U2FRegistration.ts (100%) rename {src => server}/types/dovehash.d.ts (100%) rename {src/server/lib/routes/secondfactor/u2f/sign_request => shared}/SignMessage.ts (98%) rename src/server/endpoints.ts => shared/api.ts (100%) rename {src/server => shared}/constants.ts (100%) rename {src => shared}/types/u2f.d.ts (100%) delete mode 100644 src/types/ldapjs-async.d.ts delete mode 100644 src/types/nedb-async.d.ts delete mode 100644 src/types/request-async.d.ts diff --git a/.gitignore b/.gitignore index f80f27d26..d39149ef5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ dist/ /config.yml example/ldap/private.ldif + +package-lock.json diff --git a/Dockerfile b/Dockerfile index 63b6d3eb4..7700fd8d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,8 @@ WORKDIR /usr/src COPY package.json /usr/src/package.json RUN npm install --production -COPY dist/src/server /usr/src +COPY dist/server /usr/src/server +COPY dist/shared /usr/src/shared ENV PORT=80 EXPOSE 80 @@ -13,4 +14,4 @@ EXPOSE 80 VOLUME /etc/authelia VOLUME /var/lib/authelia -CMD ["node", "index.js", "/etc/authelia/config.yml"] +CMD ["node", "server/src/index.js", "/etc/authelia/config.yml"] diff --git a/Gruntfile.js b/Gruntfile.js index 1dd853675..3837d2eeb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,75 +2,90 @@ module.exports = function (grunt) { const buildDir = "dist"; grunt.initConfig({ + env: { + "env-test-server-unit": { + TS_NODE_PROJECT: "server" + }, + "env-test-client-unit": { + TS_NODE_PROJECT: "client" + } + }, run: { - options: {}, - "build": { + "compile-server": { cmd: "./node_modules/.bin/tsc", - args: ['-p', 'tsconfig.json'] + args: ['-p', 'server/tsconfig.json'] }, - "tslint": { + "compile-client": { + cmd: "./node_modules/.bin/tsc", + args: ['-p', 'client/tsconfig.json'] + }, + "lint-server": { cmd: "./node_modules/.bin/tslint", - args: ['-c', 'tslint.json', '-p', 'tsconfig.json'] + args: ['-c', 'server/tslint.json', '-p', 'server/tsconfig.json'] }, - "unit-tests": { + "lint-client": { + cmd: "./node_modules/.bin/tslint", + args: ['-c', 'client/tslint.json', '-p', 'client/tsconfig.json'] + }, + "test-server-unit": { cmd: "./node_modules/.bin/mocha", - args: ['--compilers', 'ts:ts-node/register', '--recursive', 'test/unit'] + args: ['--colors', '--compilers', 'ts:ts-node/register', '--recursive', 'server/test'] }, - "integration-tests": { + "test-client-unit": { + cmd: "./node_modules/.bin/mocha", + args: ['--colors', '--compilers', 'ts:ts-node/register', '--recursive', 'client/test'] + }, + "test-int": { cmd: "./node_modules/.bin/cucumber-js", - args: ["--compiler", "ts:ts-node/register", "./test/features"] + args: ["--colors", "--compiler", "ts:ts-node/register", "./test/features"] }, "docker-build": { cmd: "docker", args: ['build', '-t', 'clems4ever/authelia', '.'] }, - "docker-restart": { - cmd: "./scripts/dc-dev.sh", - args: ['restart', 'authelia'] - }, "minify": { cmd: "./node_modules/.bin/uglifyjs", - args: [`${buildDir}/src/server/public_html/js/authelia.js`, '-o', `${buildDir}/src/server/public_html/js/authelia.min.js`] + args: [`${buildDir}/server/src/public_html/js/authelia.js`, '-o', `${buildDir}/server/src/public_html/js/authelia.min.js`] }, "apidoc": { cmd: "./node_modules/.bin/apidoc", args: ["-i", "src/server", "-o", "doc"] }, - "make-dev-views": { + "include-minified-script": { cmd: "sed", - args: ["-i", "s/authelia\.min/authelia/", `${buildDir}/src/server/views/layout/layout.pug`] + args: ["-i", "s/authelia\.min/authelia/", `${buildDir}/server/src/views/layout/layout.pug`] } }, copy: { resources: { expand: true, - cwd: 'src/server/resources/', + cwd: 'server/src/resources/', src: '**', - dest: `${buildDir}/src/server/resources/` + dest: `${buildDir}/server/src/resources/` }, views: { expand: true, - cwd: 'src/server/views/', + cwd: 'server/src/views/', src: '**', - dest: `${buildDir}/src/server/views/` + dest: `${buildDir}/server/src/views/` }, images: { expand: true, - cwd: 'src/client/img', + cwd: 'client/src/img', src: '**', - dest: `${buildDir}/src/server/public_html/img/` + dest: `${buildDir}/server/src/public_html/img/` }, thirdparties: { expand: true, - cwd: 'src/client/thirdparties', + cwd: 'client/src/thirdparties', src: '**', - dest: `${buildDir}/src/server/public_html/js/` + dest: `${buildDir}/server/src/public_html/js/` }, }, browserify: { dist: { - src: ['dist/src/client/index.js'], - dest: `${buildDir}/src/server/public_html/js/authelia.js`, + src: ['dist/client/src/index.js'], + dest: `${buildDir}/server/src/public_html/js/authelia.js`, options: { browserifyOptions: { standalone: 'authelia' @@ -80,7 +95,7 @@ module.exports = function (grunt) { }, watch: { views: { - files: ['src/server/views/**/*.pug'], + files: ['server/src/views/**/*.pug'], tasks: ['copy:views'], options: { interrupt: false, @@ -88,7 +103,7 @@ module.exports = function (grunt) { } }, resources: { - files: ['src/server/resources/*.ejs'], + files: ['server/src/resources/*.ejs'], tasks: ['copy:resources'], options: { interrupt: false, @@ -96,7 +111,7 @@ module.exports = function (grunt) { } }, images: { - files: ['src/client/img/**'], + files: ['client/src/img/**'], tasks: ['copy:images'], options: { interrupt: false, @@ -104,7 +119,7 @@ module.exports = function (grunt) { } }, css: { - files: ['src/client/**/*.css'], + files: ['client/src/**/*.css'], tasks: ['concat:css', 'cssmin'], options: { interrupt: true, @@ -112,7 +127,7 @@ module.exports = function (grunt) { } }, client: { - files: ['src/client/**/*.ts'], + files: ['client/src/**/*.ts'], tasks: ['build-dev'], options: { interrupt: true, @@ -120,7 +135,7 @@ module.exports = function (grunt) { } }, server: { - files: ['src/server/**/*.ts'], + files: ['server/src/**/*.ts'], tasks: ['build-dev', 'run:docker-restart', 'run:make-dev-views' ], options: { interrupt: true, @@ -130,14 +145,14 @@ module.exports = function (grunt) { }, concat: { css: { - src: ['src/client/css/*.css'], - dest: `${buildDir}/src/server/public_html/css/authelia.css` + src: ['client/src/css/*.css'], + dest: `${buildDir}/server/src/public_html/css/authelia.css` }, }, cssmin: { target: { files: { - [`${buildDir}/src/server/public_html/css/authelia.min.css`]: [`${buildDir}/src/server/public_html/css/authelia.css`] + [`${buildDir}/server/src/public_html/css/authelia.min.css`]: [`${buildDir}/server/src/public_html/css/authelia.css`] } } } @@ -149,20 +164,26 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-run'); + grunt.loadNpmTasks('grunt-env'); - grunt.registerTask('default', ['build-dist']); - grunt.registerTask('build-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']); + grunt.registerTask('compile-server', ['run:lint-server', 'run:compile-server']) + grunt.registerTask('compile-client', ['run:lint-client', 'run:compile-client']) - grunt.registerTask('build-common', ['run:tslint', 'run:build', 'browserify:dist', 'build-resources']); - grunt.registerTask('build-dev', ['build-common', 'run:make-dev-views']); - grunt.registerTask('build-dist', ['build-common', 'run:minify', 'cssmin']); + grunt.registerTask('test-server', ['env:env-test-server-unit', 'run:test-server-unit']) + grunt.registerTask('test-client', ['env:env-test-client-unit', 'run:test-client-unit']) + grunt.registerTask('test-unit', ['test-server', 'test-client']); + grunt.registerTask('test-int', ['run:test-int']); + + grunt.registerTask('copy-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']); + + grunt.registerTask('build-client', ['compile-client', 'browserify']); + grunt.registerTask('build-server', ['compile-server', 'copy-resources']); + + grunt.registerTask('build', ['build-client', 'build-server']); + grunt.registerTask('build-dist', ['build', 'run:minify', 'cssmin', 'run:include-minified-script']); grunt.registerTask('docker-build', ['run:docker-build']); - grunt.registerTask('docker-restart', ['run:docker-restart']); - grunt.registerTask('unit-tests', ['run:unit-tests']); - grunt.registerTask('integration-tests', ['run:integration-tests']); - - grunt.registerTask('test', ['unit-tests']); + grunt.registerTask('default', ['build-dist']); }; diff --git a/src/client/css/00-bootstrap.min.css b/client/src/css/00-bootstrap.min.css similarity index 100% rename from src/client/css/00-bootstrap.min.css rename to client/src/css/00-bootstrap.min.css diff --git a/src/client/css/01-main.css b/client/src/css/01-main.css similarity index 100% rename from src/client/css/01-main.css rename to client/src/css/01-main.css diff --git a/src/client/css/02-login.css b/client/src/css/02-login.css similarity index 100% rename from src/client/css/02-login.css rename to client/src/css/02-login.css diff --git a/src/client/css/03-errors.css b/client/src/css/03-errors.css similarity index 100% rename from src/client/css/03-errors.css rename to client/src/css/03-errors.css diff --git a/src/client/css/03-password-reset-form.css b/client/src/css/03-password-reset-form.css similarity index 100% rename from src/client/css/03-password-reset-form.css rename to client/src/css/03-password-reset-form.css diff --git a/src/client/css/03-password-reset-request.css b/client/src/css/03-password-reset-request.css similarity index 100% rename from src/client/css/03-password-reset-request.css rename to client/src/css/03-password-reset-request.css diff --git a/src/client/css/03-totp-register.css b/client/src/css/03-totp-register.css similarity index 100% rename from src/client/css/03-totp-register.css rename to client/src/css/03-totp-register.css diff --git a/src/client/css/03-u2f-register.css b/client/src/css/03-u2f-register.css similarity index 100% rename from src/client/css/03-u2f-register.css rename to client/src/css/03-u2f-register.css diff --git a/src/client/img/icon.png b/client/src/img/icon.png similarity index 100% rename from src/client/img/icon.png rename to client/src/img/icon.png diff --git a/src/client/img/mail.png b/client/src/img/mail.png similarity index 100% rename from src/client/img/mail.png rename to client/src/img/mail.png diff --git a/src/client/img/padlock.png b/client/src/img/padlock.png similarity index 100% rename from src/client/img/padlock.png rename to client/src/img/padlock.png diff --git a/src/client/img/password.png b/client/src/img/password.png similarity index 100% rename from src/client/img/password.png rename to client/src/img/password.png diff --git a/src/client/img/pendrive.png b/client/src/img/pendrive.png similarity index 100% rename from src/client/img/pendrive.png rename to client/src/img/pendrive.png diff --git a/src/client/img/success.png b/client/src/img/success.png similarity index 100% rename from src/client/img/success.png rename to client/src/img/success.png diff --git a/src/client/img/user.png b/client/src/img/user.png similarity index 100% rename from src/client/img/user.png rename to client/src/img/user.png diff --git a/src/client/img/warning.png b/client/src/img/warning.png similarity index 100% rename from src/client/img/warning.png rename to client/src/img/warning.png diff --git a/src/client/index.ts b/client/src/index.ts similarity index 92% rename from src/client/index.ts rename to client/src/index.ts index 956edfc0b..8c60127f9 100644 --- a/src/client/index.ts +++ b/client/src/index.ts @@ -9,7 +9,7 @@ import ResetPasswordRequest from "./lib/reset-password/reset-password-request"; import ResetPasswordForm from "./lib/reset-password/reset-password-form"; import jslogger = require("js-logger"); import jQuery = require("jquery"); -import u2fApi = require("u2f-api"); +import U2fApi = require("u2f-api"); jslogger.useDefaults(); jslogger.setLevel(jslogger.INFO); @@ -19,7 +19,7 @@ export = { FirstFactor(window, jQuery, FirstFactorValidator, jslogger); }, secondfactor: function () { - SecondFactor(window, jQuery, u2fApi); + SecondFactor(window, jQuery, U2fApi); }, register_totp: function() { TOTPRegister(window, jQuery); diff --git a/src/client/lib/INotifier.ts b/client/src/lib/INotifier.ts similarity index 100% rename from src/client/lib/INotifier.ts rename to client/src/lib/INotifier.ts diff --git a/src/client/lib/Notifier.ts b/client/src/lib/Notifier.ts similarity index 100% rename from src/client/lib/Notifier.ts rename to client/src/lib/Notifier.ts diff --git a/src/client/lib/QueryParametersRetriever.ts b/client/src/lib/QueryParametersRetriever.ts similarity index 100% rename from src/client/lib/QueryParametersRetriever.ts rename to client/src/lib/QueryParametersRetriever.ts diff --git a/src/client/lib/firstfactor/FirstFactorValidator.ts b/client/src/lib/firstfactor/FirstFactorValidator.ts similarity index 87% rename from src/client/lib/firstfactor/FirstFactorValidator.ts rename to client/src/lib/firstfactor/FirstFactorValidator.ts index 32dc421c8..b7bda3b4d 100644 --- a/src/client/lib/firstfactor/FirstFactorValidator.ts +++ b/client/src/lib/firstfactor/FirstFactorValidator.ts @@ -1,7 +1,7 @@ import BluebirdPromise = require("bluebird"); -import Endpoints = require("../../../server/endpoints"); -import Constants = require("../../../server/constants"); +import Endpoints = require("../../../../shared/api"); +import Constants = require("../../../../shared/constants"); export function validate(username: string, password: string, redirectUrl: string, onlyBasicAuth: boolean, $: JQueryStatic): BluebirdPromise { diff --git a/src/client/lib/firstfactor/UISelectors.ts b/client/src/lib/firstfactor/UISelectors.ts similarity index 100% rename from src/client/lib/firstfactor/UISelectors.ts rename to client/src/lib/firstfactor/UISelectors.ts diff --git a/src/client/lib/firstfactor/index.ts b/client/src/lib/firstfactor/index.ts similarity index 92% rename from src/client/lib/firstfactor/index.ts rename to client/src/lib/firstfactor/index.ts index a4fd48299..fc897ff1d 100644 --- a/src/client/lib/firstfactor/index.ts +++ b/client/src/lib/firstfactor/index.ts @@ -3,8 +3,8 @@ import JSLogger = require("js-logger"); import UISelectors = require("./UISelectors"); import { Notifier } from "../Notifier"; import { QueryParametersRetriever } from "../QueryParametersRetriever"; -import Constants = require("../../../server/constants"); -import Endpoints = require("../../../server/endpoints"); +import Constants = require("../../../../shared/constants"); +import Endpoints = require("../../../../shared/api"); export default function (window: Window, $: JQueryStatic, firstFactorValidator: typeof FirstFactorValidator, jslogger: typeof JSLogger) { diff --git a/src/client/lib/reset-password/constants.ts b/client/src/lib/reset-password/constants.ts similarity index 100% rename from src/client/lib/reset-password/constants.ts rename to client/src/lib/reset-password/constants.ts diff --git a/src/client/lib/reset-password/reset-password-form.ts b/client/src/lib/reset-password/reset-password-form.ts similarity index 96% rename from src/client/lib/reset-password/reset-password-form.ts rename to client/src/lib/reset-password/reset-password-form.ts index 26ec4ec1d..12f60d777 100644 --- a/src/client/lib/reset-password/reset-password-form.ts +++ b/client/src/lib/reset-password/reset-password-form.ts @@ -1,6 +1,6 @@ import BluebirdPromise = require("bluebird"); -import Endpoints = require("../../../server/endpoints"); +import Endpoints = require("../../../../shared/api"); import Constants = require("./constants"); import { Notifier } from "../Notifier"; diff --git a/src/client/lib/reset-password/reset-password-request.ts b/client/src/lib/reset-password/reset-password-request.ts similarity index 96% rename from src/client/lib/reset-password/reset-password-request.ts rename to client/src/lib/reset-password/reset-password-request.ts index 8ff450f40..0685e1760 100644 --- a/src/client/lib/reset-password/reset-password-request.ts +++ b/client/src/lib/reset-password/reset-password-request.ts @@ -1,7 +1,7 @@ import BluebirdPromise = require("bluebird"); -import Endpoints = require("../../../server/endpoints"); +import Endpoints = require("../../../../shared/api"); import Constants = require("./constants"); import jslogger = require("js-logger"); import { Notifier } from "../Notifier"; diff --git a/src/client/lib/secondfactor/TOTPValidator.ts b/client/src/lib/secondfactor/TOTPValidator.ts similarity index 91% rename from src/client/lib/secondfactor/TOTPValidator.ts rename to client/src/lib/secondfactor/TOTPValidator.ts index 4b1d0ffbe..824b591a7 100644 --- a/src/client/lib/secondfactor/TOTPValidator.ts +++ b/client/src/lib/secondfactor/TOTPValidator.ts @@ -1,6 +1,6 @@ import BluebirdPromise = require("bluebird"); -import Endpoints = require("../../../server/endpoints"); +import Endpoints = require("../../../../shared/api"); export function validate(token: string, $: JQueryStatic): BluebirdPromise { return new BluebirdPromise(function (resolve, reject) { diff --git a/src/client/lib/secondfactor/U2FValidator.ts b/client/src/lib/secondfactor/U2FValidator.ts similarity index 93% rename from src/client/lib/secondfactor/U2FValidator.ts rename to client/src/lib/secondfactor/U2FValidator.ts index b1fdb595b..66c7751aa 100644 --- a/src/client/lib/secondfactor/U2FValidator.ts +++ b/client/src/lib/secondfactor/U2FValidator.ts @@ -2,8 +2,8 @@ import U2fApi = require("u2f-api"); import U2f = require("u2f"); import BluebirdPromise = require("bluebird"); -import { SignMessage } from "../../../server/lib/routes/secondfactor/u2f/sign_request/SignMessage"; -import Endpoints = require("../../../server/endpoints"); +import { SignMessage } from "../../../../shared/SignMessage"; +import Endpoints = require("../../../../shared/api"); import { INotifier } from "../INotifier"; function finishU2fAuthentication(responseData: U2fApi.SignResponse, $: JQueryStatic): BluebirdPromise { diff --git a/src/client/lib/secondfactor/constants.ts b/client/src/lib/secondfactor/constants.ts similarity index 100% rename from src/client/lib/secondfactor/constants.ts rename to client/src/lib/secondfactor/constants.ts diff --git a/src/client/lib/secondfactor/index.ts b/client/src/lib/secondfactor/index.ts similarity index 94% rename from src/client/lib/secondfactor/index.ts rename to client/src/lib/secondfactor/index.ts index 4fe9ae940..52875254e 100644 --- a/src/client/lib/secondfactor/index.ts +++ b/client/src/lib/secondfactor/index.ts @@ -4,11 +4,11 @@ import jslogger = require("js-logger"); import TOTPValidator = require("./TOTPValidator"); import U2FValidator = require("./U2FValidator"); -import Endpoints = require("../../../server/endpoints"); import Constants = require("./constants"); import { Notifier } from "../Notifier"; import { QueryParametersRetriever } from "../QueryParametersRetriever"; -import ServerConstants = require("../../../server/constants"); +import Endpoints = require("../../../../shared/api"); +import ServerConstants = require("../../../../shared/constants"); export default function (window: Window, $: JQueryStatic, u2fApi: typeof U2fApi) { diff --git a/src/client/lib/totp-register/totp-register.ts b/client/src/lib/totp-register/totp-register.ts similarity index 100% rename from src/client/lib/totp-register/totp-register.ts rename to client/src/lib/totp-register/totp-register.ts diff --git a/src/client/lib/totp-register/ui-selector.ts b/client/src/lib/totp-register/ui-selector.ts similarity index 100% rename from src/client/lib/totp-register/ui-selector.ts rename to client/src/lib/totp-register/ui-selector.ts diff --git a/src/client/lib/u2f-register/u2f-register.ts b/client/src/lib/u2f-register/u2f-register.ts similarity index 97% rename from src/client/lib/u2f-register/u2f-register.ts rename to client/src/lib/u2f-register/u2f-register.ts index e34706bc4..f895bbf60 100644 --- a/src/client/lib/u2f-register/u2f-register.ts +++ b/client/src/lib/u2f-register/u2f-register.ts @@ -2,9 +2,9 @@ import BluebirdPromise = require("bluebird"); import U2f = require("u2f"); import u2fApi = require("u2f-api"); -import Endpoints = require("../../../server/endpoints"); import jslogger = require("js-logger"); import { Notifier } from "../Notifier"; +import Endpoints = require("../../../../shared/api"); export default function (window: Window, $: JQueryStatic) { const notifier = new Notifier(".notification", $); diff --git a/src/client/thirdparties/qrcode.min.js b/client/src/thirdparties/qrcode.min.js similarity index 100% rename from src/client/thirdparties/qrcode.min.js rename to client/src/thirdparties/qrcode.min.js diff --git a/test/unit/client/Notifier.test.ts b/client/test/Notifier.test.ts similarity index 96% rename from test/unit/client/Notifier.test.ts rename to client/test/Notifier.test.ts index 33e4331d6..70bfea146 100644 --- a/test/unit/client/Notifier.test.ts +++ b/client/test/Notifier.test.ts @@ -3,7 +3,7 @@ import Assert = require("assert"); import Sinon = require("sinon"); import JQueryMock = require("./mocks/jquery"); -import { Notifier } from "../../../src/client/lib/Notifier"; +import { Notifier } from "../src/lib/Notifier"; describe("test notifier", function() { const SELECTOR = "dummy-selector"; diff --git a/test/unit/client/firstfactor/FirstFactorValidator.test.ts b/client/test/firstfactor/FirstFactorValidator.test.ts similarity index 94% rename from test/unit/client/firstfactor/FirstFactorValidator.test.ts rename to client/test/firstfactor/FirstFactorValidator.test.ts index cf3a954cb..49e4f232c 100644 --- a/test/unit/client/firstfactor/FirstFactorValidator.test.ts +++ b/client/test/firstfactor/FirstFactorValidator.test.ts @@ -1,5 +1,5 @@ -import FirstFactorValidator = require("../../../../src/client/lib/firstfactor/FirstFactorValidator"); +import FirstFactorValidator = require("../../src/lib/firstfactor/FirstFactorValidator"); import JQueryMock = require("../mocks/jquery"); import BluebirdPromise = require("bluebird"); import Assert = require("assert"); diff --git a/test/unit/client/mocks/NotifierStub.ts b/client/test/mocks/NotifierStub.ts similarity index 89% rename from test/unit/client/mocks/NotifierStub.ts rename to client/test/mocks/NotifierStub.ts index 66cf37696..9c268d66d 100644 --- a/test/unit/client/mocks/NotifierStub.ts +++ b/client/test/mocks/NotifierStub.ts @@ -1,6 +1,6 @@ import Sinon = require("sinon"); -import { INotifier } from "../../../../src/client/lib/INotifier"; +import { INotifier } from "../../src/lib/INotifier"; export class NotifierStub implements INotifier { successStub: Sinon.SinonStub; diff --git a/test/unit/client/mocks/jquery.ts b/client/test/mocks/jquery.ts similarity index 100% rename from test/unit/client/mocks/jquery.ts rename to client/test/mocks/jquery.ts diff --git a/test/unit/client/mocks/u2f-api.ts b/client/test/mocks/u2f-api.ts similarity index 100% rename from test/unit/client/mocks/u2f-api.ts rename to client/test/mocks/u2f-api.ts diff --git a/test/unit/client/secondfactor/TOTPValidator.test.ts b/client/test/secondfactor/TOTPValidator.test.ts similarity index 93% rename from test/unit/client/secondfactor/TOTPValidator.test.ts rename to client/test/secondfactor/TOTPValidator.test.ts index c2fa57d61..e03b0b9ad 100644 --- a/test/unit/client/secondfactor/TOTPValidator.test.ts +++ b/client/test/secondfactor/TOTPValidator.test.ts @@ -1,5 +1,5 @@ -import TOTPValidator = require("../../../../src/client/lib/secondfactor/TOTPValidator"); +import TOTPValidator = require("../../src/lib/secondfactor/TOTPValidator"); import JQueryMock = require("../mocks/jquery"); import BluebirdPromise = require("bluebird"); import Assert = require("assert"); diff --git a/test/unit/client/secondfactor/U2FValidator.test.ts b/client/test/secondfactor/U2FValidator.test.ts similarity index 94% rename from test/unit/client/secondfactor/U2FValidator.test.ts rename to client/test/secondfactor/U2FValidator.test.ts index c464715a4..c57906a4a 100644 --- a/test/unit/client/secondfactor/U2FValidator.test.ts +++ b/client/test/secondfactor/U2FValidator.test.ts @@ -1,9 +1,9 @@ -import U2FValidator = require("../../../../src/client/lib/secondfactor/U2FValidator"); -import { INotifier } from "../../../../src/client/lib/INotifier"; +import U2FValidator = require("../../src/lib/secondfactor/U2FValidator"); +import { INotifier } from "../../src/lib/INotifier"; import JQueryMock = require("../mocks/jquery"); import U2FApiMock = require("../mocks/u2f-api"); -import { SignMessage } from "../../../../src/server/lib/routes/secondfactor/u2f/sign_request/SignMessage"; +import { SignMessage } from "../../../shared/SignMessage"; import BluebirdPromise = require("bluebird"); import Assert = require("assert"); import { NotifierStub } from "../mocks/NotifierStub"; diff --git a/test/unit/client/totp-register/totp-register.test.ts b/client/test/totp-register/totp-register.test.ts similarity index 79% rename from test/unit/client/totp-register/totp-register.test.ts rename to client/test/totp-register/totp-register.test.ts index 5e97a84e8..86fc455a1 100644 --- a/test/unit/client/totp-register/totp-register.test.ts +++ b/client/test/totp-register/totp-register.test.ts @@ -2,8 +2,8 @@ import sinon = require("sinon"); import assert = require("assert"); -import UISelector = require("../../../../src/client/lib/totp-register/ui-selector"); -import TOTPRegister = require("../../../../src/client/lib/totp-register/totp-register"); +import UISelector = require("../../src/lib/totp-register/ui-selector"); +import TOTPRegister = require("../../src/lib/totp-register/totp-register"); describe("test totp-register", function() { let jqueryMock: any; diff --git a/tsconfig.json b/client/tsconfig.json similarity index 68% rename from tsconfig.json rename to client/tsconfig.json index f59e34c0e..0bb4d62ff 100644 --- a/tsconfig.json +++ b/client/tsconfig.json @@ -6,17 +6,19 @@ "noImplicitAny": true, "sourceMap": true, "removeComments": true, - "outDir": "dist", + "outDir": "../dist", "baseUrl": ".", "paths": { "*": [ - "./src/types/*", - "./node_modules/@types/*" + "./types/*", + "../shared/types/*" ] } }, - "includes": [ - "src/**/*", + "include": [ + "src/**/*" + ], + "exclude": [ "test/**/*" ] } diff --git a/tslint.json b/client/tslint.json similarity index 100% rename from tslint.json rename to client/tslint.json diff --git a/src/types/u2f-api.d.ts b/client/types/u2f-api.d.ts similarity index 100% rename from src/types/u2f-api.d.ts rename to client/types/u2f-api.d.ts diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 196ecac5f..083b5763c 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -3,7 +3,8 @@ services: authelia: volumes: - ./test:/usr/src/test - - ./dist/src/server:/usr/src + - ./dist/server:/usr/src/server + - ./dist/shared:/usr/src/shared - ./node_modules:/usr/src/node_modules - ./config.template.yml:/etc/authelia/config.yml:ro networks: diff --git a/package.json b/package.json index 7f31f9f19..e9523063b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "3.4.0", "description": "2FA Single Sign-On server for nginx using LDAP, TOTP and U2F", "bin": { - "authelia": "./dist/src/server/index.js" + "authelia": "./dist/server/src/index.js" }, "scripts": { "test": "./node_modules/.bin/grunt unit-tests", @@ -83,6 +83,7 @@ "grunt-contrib-copy": "^1.0.0", "grunt-contrib-cssmin": "^2.2.0", "grunt-contrib-watch": "^1.0.0", + "grunt-env": "^0.4.4", "grunt-run": "^0.6.0", "istanbul": "^0.4.5", "jquery": "^3.2.1", diff --git a/scripts/integration-tests.sh b/scripts/integration-tests.sh index 59c9bf15d..1cabe9bca 100755 --- a/scripts/integration-tests.sh +++ b/scripts/integration-tests.sh @@ -3,6 +3,10 @@ DC_SCRIPT=./scripts/example-commit/dc-example.sh EXPECTED_SERVICES_COUNT=6 +build_services() { + $DC_SCRIPT build authelia +} + start_services() { $DC_SCRIPT up -d mongo redis openldap authelia nginx smtp sleep 3 @@ -32,7 +36,7 @@ run_integration_tests() { expect_services_count $EXPECTED_SERVICES_COUNT sleep 5 - ./node_modules/.bin/grunt run:integration-tests + ./node_modules/.bin/grunt run:test-int shut_services } @@ -59,6 +63,9 @@ set -e echo "Make sure services are not already running" shut_services +# Build the container +build_services + # Prepare & test example from end user perspective run_integration_tests diff --git a/scripts/travis.sh b/scripts/travis.sh index 7fcb42f3b..97e2c5454 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -6,7 +6,7 @@ docker --version docker-compose --version # Run unit tests -grunt test +grunt test-unit # Build the app from Typescript and package grunt build-dist diff --git a/src/server/index.ts b/server/src/index.ts similarity index 100% rename from src/server/index.ts rename to server/src/index.ts diff --git a/src/server/lib/AuthenticationRegulator.ts b/server/src/lib/AuthenticationRegulator.ts similarity index 100% rename from src/server/lib/AuthenticationRegulator.ts rename to server/src/lib/AuthenticationRegulator.ts diff --git a/src/server/lib/AuthenticationSession.ts b/server/src/lib/AuthenticationSession.ts similarity index 100% rename from src/server/lib/AuthenticationSession.ts rename to server/src/lib/AuthenticationSession.ts diff --git a/src/server/lib/AuthenticationValidator.ts b/server/src/lib/AuthenticationValidator.ts similarity index 100% rename from src/server/lib/AuthenticationValidator.ts rename to server/src/lib/AuthenticationValidator.ts diff --git a/src/server/lib/ErrorReplies.ts b/server/src/lib/ErrorReplies.ts similarity index 100% rename from src/server/lib/ErrorReplies.ts rename to server/src/lib/ErrorReplies.ts diff --git a/src/server/lib/Exceptions.ts b/server/src/lib/Exceptions.ts similarity index 100% rename from src/server/lib/Exceptions.ts rename to server/src/lib/Exceptions.ts diff --git a/src/server/lib/FirstFactorValidator.ts b/server/src/lib/FirstFactorValidator.ts similarity index 100% rename from src/server/lib/FirstFactorValidator.ts rename to server/src/lib/FirstFactorValidator.ts diff --git a/src/server/lib/IdentityCheckMiddleware.ts b/server/src/lib/IdentityCheckMiddleware.ts similarity index 100% rename from src/server/lib/IdentityCheckMiddleware.ts rename to server/src/lib/IdentityCheckMiddleware.ts diff --git a/src/server/lib/IdentityCheckPreValidationTemplate.ts b/server/src/lib/IdentityCheckPreValidationTemplate.ts similarity index 100% rename from src/server/lib/IdentityCheckPreValidationTemplate.ts rename to server/src/lib/IdentityCheckPreValidationTemplate.ts diff --git a/src/server/lib/RestApi.ts b/server/src/lib/RestApi.ts similarity index 98% rename from src/server/lib/RestApi.ts rename to server/src/lib/RestApi.ts index efea69063..67b7af3c7 100644 --- a/src/server/lib/RestApi.ts +++ b/server/src/lib/RestApi.ts @@ -31,7 +31,7 @@ import Error403Get = require("./routes/error/403/get"); import Error404Get = require("./routes/error/404/get"); import { ServerVariablesHandler } from "./ServerVariablesHandler"; -import Endpoints = require("../endpoints"); +import Endpoints = require("../../../shared/api"); function withLog(fn: (req: Express.Request, res: Express.Response) => void) { return function(req: Express.Request, res: Express.Response) { diff --git a/src/server/lib/Server.ts b/server/src/lib/Server.ts similarity index 100% rename from src/server/lib/Server.ts rename to server/src/lib/Server.ts diff --git a/src/server/lib/ServerVariablesHandler.ts b/server/src/lib/ServerVariablesHandler.ts similarity index 100% rename from src/server/lib/ServerVariablesHandler.ts rename to server/src/lib/ServerVariablesHandler.ts diff --git a/src/server/lib/TOTPGenerator.ts b/server/src/lib/TOTPGenerator.ts similarity index 100% rename from src/server/lib/TOTPGenerator.ts rename to server/src/lib/TOTPGenerator.ts diff --git a/src/server/lib/TOTPValidator.ts b/server/src/lib/TOTPValidator.ts similarity index 100% rename from src/server/lib/TOTPValidator.ts rename to server/src/lib/TOTPValidator.ts diff --git a/src/server/lib/access_control/AccessController.ts b/server/src/lib/access_control/AccessController.ts similarity index 100% rename from src/server/lib/access_control/AccessController.ts rename to server/src/lib/access_control/AccessController.ts diff --git a/src/server/lib/access_control/DomainMatcher.ts b/server/src/lib/access_control/DomainMatcher.ts similarity index 100% rename from src/server/lib/access_control/DomainMatcher.ts rename to server/src/lib/access_control/DomainMatcher.ts diff --git a/src/server/lib/access_control/IAccessController.ts b/server/src/lib/access_control/IAccessController.ts similarity index 100% rename from src/server/lib/access_control/IAccessController.ts rename to server/src/lib/access_control/IAccessController.ts diff --git a/src/server/lib/configuration/Configuration.d.ts b/server/src/lib/configuration/Configuration.d.ts similarity index 100% rename from src/server/lib/configuration/Configuration.d.ts rename to server/src/lib/configuration/Configuration.d.ts diff --git a/src/server/lib/configuration/ConfigurationAdapter.ts b/server/src/lib/configuration/ConfigurationAdapter.ts similarity index 100% rename from src/server/lib/configuration/ConfigurationAdapter.ts rename to server/src/lib/configuration/ConfigurationAdapter.ts diff --git a/src/server/lib/configuration/SessionConfigurationBuilder.ts b/server/src/lib/configuration/SessionConfigurationBuilder.ts similarity index 100% rename from src/server/lib/configuration/SessionConfigurationBuilder.ts rename to server/src/lib/configuration/SessionConfigurationBuilder.ts diff --git a/src/server/lib/connectors/mongo/IMongoClient.d.ts b/server/src/lib/connectors/mongo/IMongoClient.d.ts similarity index 100% rename from src/server/lib/connectors/mongo/IMongoClient.d.ts rename to server/src/lib/connectors/mongo/IMongoClient.d.ts diff --git a/src/server/lib/connectors/mongo/IMongoConnector.d.ts b/server/src/lib/connectors/mongo/IMongoConnector.d.ts similarity index 100% rename from src/server/lib/connectors/mongo/IMongoConnector.d.ts rename to server/src/lib/connectors/mongo/IMongoConnector.d.ts diff --git a/src/server/lib/connectors/mongo/IMongoConnectorFactory.d.ts b/server/src/lib/connectors/mongo/IMongoConnectorFactory.d.ts similarity index 100% rename from src/server/lib/connectors/mongo/IMongoConnectorFactory.d.ts rename to server/src/lib/connectors/mongo/IMongoConnectorFactory.d.ts diff --git a/src/server/lib/connectors/mongo/MongoClient.ts b/server/src/lib/connectors/mongo/MongoClient.ts similarity index 100% rename from src/server/lib/connectors/mongo/MongoClient.ts rename to server/src/lib/connectors/mongo/MongoClient.ts diff --git a/src/server/lib/connectors/mongo/MongoConnector.ts b/server/src/lib/connectors/mongo/MongoConnector.ts similarity index 100% rename from src/server/lib/connectors/mongo/MongoConnector.ts rename to server/src/lib/connectors/mongo/MongoConnector.ts diff --git a/src/server/lib/connectors/mongo/MongoConnectorFactory.ts b/server/src/lib/connectors/mongo/MongoConnectorFactory.ts similarity index 100% rename from src/server/lib/connectors/mongo/MongoConnectorFactory.ts rename to server/src/lib/connectors/mongo/MongoConnectorFactory.ts diff --git a/src/server/lib/ldap/Authenticator.ts b/server/src/lib/ldap/Authenticator.ts similarity index 100% rename from src/server/lib/ldap/Authenticator.ts rename to server/src/lib/ldap/Authenticator.ts diff --git a/src/server/lib/ldap/Client.ts b/server/src/lib/ldap/Client.ts similarity index 93% rename from src/server/lib/ldap/Client.ts rename to server/src/lib/ldap/Client.ts index ea3da1b60..834f8b1ef 100644 --- a/src/server/lib/ldap/Client.ts +++ b/server/src/lib/ldap/Client.ts @@ -14,6 +14,16 @@ interface SearchEntry { object: any; } +declare module "ldapjs" { + export interface ClientAsync { + on(event: string, callback: (data?: any) => void): void; + bindAsync(username: string, password: string): BluebirdPromise; + unbindAsync(): BluebirdPromise; + searchAsync(base: string, query: Ldapjs.SearchOptions): BluebirdPromise; + modifyAsync(userdn: string, change: Ldapjs.Change): BluebirdPromise; + } +} + export class Client implements IClient { private userDN: string; private password: string; diff --git a/src/server/lib/ldap/ClientFactory.ts b/server/src/lib/ldap/ClientFactory.ts similarity index 100% rename from src/server/lib/ldap/ClientFactory.ts rename to server/src/lib/ldap/ClientFactory.ts diff --git a/src/server/lib/ldap/EmailsRetriever.ts b/server/src/lib/ldap/EmailsRetriever.ts similarity index 100% rename from src/server/lib/ldap/EmailsRetriever.ts rename to server/src/lib/ldap/EmailsRetriever.ts diff --git a/src/server/lib/ldap/IAuthenticator.ts b/server/src/lib/ldap/IAuthenticator.ts similarity index 100% rename from src/server/lib/ldap/IAuthenticator.ts rename to server/src/lib/ldap/IAuthenticator.ts diff --git a/src/server/lib/ldap/IClient.ts b/server/src/lib/ldap/IClient.ts similarity index 100% rename from src/server/lib/ldap/IClient.ts rename to server/src/lib/ldap/IClient.ts diff --git a/src/server/lib/ldap/IClientFactory.ts b/server/src/lib/ldap/IClientFactory.ts similarity index 100% rename from src/server/lib/ldap/IClientFactory.ts rename to server/src/lib/ldap/IClientFactory.ts diff --git a/src/server/lib/ldap/IEmailsRetriever.ts b/server/src/lib/ldap/IEmailsRetriever.ts similarity index 100% rename from src/server/lib/ldap/IEmailsRetriever.ts rename to server/src/lib/ldap/IEmailsRetriever.ts diff --git a/src/server/lib/ldap/IPasswordUpdater.ts b/server/src/lib/ldap/IPasswordUpdater.ts similarity index 100% rename from src/server/lib/ldap/IPasswordUpdater.ts rename to server/src/lib/ldap/IPasswordUpdater.ts diff --git a/src/server/lib/ldap/PasswordUpdater.ts b/server/src/lib/ldap/PasswordUpdater.ts similarity index 100% rename from src/server/lib/ldap/PasswordUpdater.ts rename to server/src/lib/ldap/PasswordUpdater.ts diff --git a/src/server/lib/notifiers/AbstractEmailNotifier.ts b/server/src/lib/notifiers/AbstractEmailNotifier.ts similarity index 100% rename from src/server/lib/notifiers/AbstractEmailNotifier.ts rename to server/src/lib/notifiers/AbstractEmailNotifier.ts diff --git a/src/server/lib/notifiers/GMailNotifier.ts b/server/src/lib/notifiers/GMailNotifier.ts similarity index 100% rename from src/server/lib/notifiers/GMailNotifier.ts rename to server/src/lib/notifiers/GMailNotifier.ts diff --git a/src/server/lib/notifiers/INotifier.d.ts b/server/src/lib/notifiers/INotifier.d.ts similarity index 100% rename from src/server/lib/notifiers/INotifier.d.ts rename to server/src/lib/notifiers/INotifier.d.ts diff --git a/src/server/lib/notifiers/NotifierFactory.ts b/server/src/lib/notifiers/NotifierFactory.ts similarity index 100% rename from src/server/lib/notifiers/NotifierFactory.ts rename to server/src/lib/notifiers/NotifierFactory.ts diff --git a/src/server/lib/notifiers/SmtpNotifier.ts b/server/src/lib/notifiers/SmtpNotifier.ts similarity index 100% rename from src/server/lib/notifiers/SmtpNotifier.ts rename to server/src/lib/notifiers/SmtpNotifier.ts diff --git a/src/server/lib/routes/FirstFactorBlocker.ts b/server/src/lib/routes/FirstFactorBlocker.ts similarity index 100% rename from src/server/lib/routes/FirstFactorBlocker.ts rename to server/src/lib/routes/FirstFactorBlocker.ts diff --git a/src/server/lib/routes/error/401/get.ts b/server/src/lib/routes/error/401/get.ts similarity index 100% rename from src/server/lib/routes/error/401/get.ts rename to server/src/lib/routes/error/401/get.ts diff --git a/src/server/lib/routes/error/403/get.ts b/server/src/lib/routes/error/403/get.ts similarity index 100% rename from src/server/lib/routes/error/403/get.ts rename to server/src/lib/routes/error/403/get.ts diff --git a/src/server/lib/routes/error/404/get.ts b/server/src/lib/routes/error/404/get.ts similarity index 100% rename from src/server/lib/routes/error/404/get.ts rename to server/src/lib/routes/error/404/get.ts diff --git a/src/server/lib/routes/firstfactor/get.ts b/server/src/lib/routes/firstfactor/get.ts similarity index 92% rename from src/server/lib/routes/firstfactor/get.ts rename to server/src/lib/routes/firstfactor/get.ts index 01d8ac73f..e2ba0d087 100644 --- a/src/server/lib/routes/firstfactor/get.ts +++ b/server/src/lib/routes/firstfactor/get.ts @@ -2,7 +2,7 @@ import express = require("express"); import objectPath = require("object-path"); import winston = require("winston"); -import Endpoints = require("../../../endpoints"); +import Endpoints = require("../../../../../shared/api"); import AuthenticationValidator = require("../../AuthenticationValidator"); import { ServerVariablesHandler } from "../../ServerVariablesHandler"; import BluebirdPromise = require("bluebird"); diff --git a/src/server/lib/routes/firstfactor/post.ts b/server/src/lib/routes/firstfactor/post.ts similarity index 97% rename from src/server/lib/routes/firstfactor/post.ts rename to server/src/lib/routes/firstfactor/post.ts index 869e9d4f9..0bda38558 100644 --- a/src/server/lib/routes/firstfactor/post.ts +++ b/server/src/lib/routes/firstfactor/post.ts @@ -6,11 +6,11 @@ import express = require("express"); import { AccessController } from "../../access_control/AccessController"; import { AuthenticationRegulator } from "../../AuthenticationRegulator"; import { GroupsAndEmails } from "../../ldap/IClient"; -import Endpoint = require("../../../endpoints"); +import Endpoint = require("../../../../../shared/api"); import ErrorReplies = require("../../ErrorReplies"); import { ServerVariablesHandler } from "../../ServerVariablesHandler"; import AuthenticationSession = require("../../AuthenticationSession"); -import Constants = require("../../../constants"); +import Constants = require("../../../../../shared/constants"); export default function (req: express.Request, res: express.Response): BluebirdPromise { const username: string = req.body.username; diff --git a/src/server/lib/routes/logout/get.ts b/server/src/lib/routes/logout/get.ts similarity index 100% rename from src/server/lib/routes/logout/get.ts rename to server/src/lib/routes/logout/get.ts diff --git a/src/server/lib/routes/password-reset/constants.ts b/server/src/lib/routes/password-reset/constants.ts similarity index 100% rename from src/server/lib/routes/password-reset/constants.ts rename to server/src/lib/routes/password-reset/constants.ts diff --git a/src/server/lib/routes/password-reset/form/post.ts b/server/src/lib/routes/password-reset/form/post.ts similarity index 100% rename from src/server/lib/routes/password-reset/form/post.ts rename to server/src/lib/routes/password-reset/form/post.ts diff --git a/src/server/lib/routes/password-reset/identity/PasswordResetHandler.ts b/server/src/lib/routes/password-reset/identity/PasswordResetHandler.ts similarity index 100% rename from src/server/lib/routes/password-reset/identity/PasswordResetHandler.ts rename to server/src/lib/routes/password-reset/identity/PasswordResetHandler.ts diff --git a/src/server/lib/routes/password-reset/request/get.ts b/server/src/lib/routes/password-reset/request/get.ts similarity index 100% rename from src/server/lib/routes/password-reset/request/get.ts rename to server/src/lib/routes/password-reset/request/get.ts diff --git a/src/server/lib/routes/secondfactor/get.ts b/server/src/lib/routes/secondfactor/get.ts similarity index 93% rename from src/server/lib/routes/secondfactor/get.ts rename to server/src/lib/routes/secondfactor/get.ts index f7520fae1..ba0330362 100644 --- a/src/server/lib/routes/secondfactor/get.ts +++ b/server/src/lib/routes/secondfactor/get.ts @@ -1,6 +1,6 @@ import Express = require("express"); -import Endpoints = require("../../../endpoints"); +import Endpoints = require("../../../../../shared/api"); import FirstFactorBlocker = require("../FirstFactorBlocker"); import BluebirdPromise = require("bluebird"); import { ServerVariablesHandler } from "../../ServerVariablesHandler"; diff --git a/src/server/lib/routes/secondfactor/redirect.ts b/server/src/lib/routes/secondfactor/redirect.ts similarity index 92% rename from src/server/lib/routes/secondfactor/redirect.ts rename to server/src/lib/routes/secondfactor/redirect.ts index 0ab94845d..75ff801df 100644 --- a/src/server/lib/routes/secondfactor/redirect.ts +++ b/server/src/lib/routes/secondfactor/redirect.ts @@ -2,7 +2,7 @@ import express = require("express"); import objectPath = require("object-path"); import winston = require("winston"); -import Endpoints = require("../../../endpoints"); +import Endpoints = require("../../../../../shared/api"); import { ServerVariablesHandler } from "../../ServerVariablesHandler"; import AuthenticationSession = require("../../AuthenticationSession"); import BluebirdPromise = require("bluebird"); diff --git a/src/server/lib/routes/secondfactor/totp/constants.ts b/server/src/lib/routes/secondfactor/totp/constants.ts similarity index 100% rename from src/server/lib/routes/secondfactor/totp/constants.ts rename to server/src/lib/routes/secondfactor/totp/constants.ts diff --git a/src/server/lib/routes/secondfactor/totp/identity/RegistrationHandler.ts b/server/src/lib/routes/secondfactor/totp/identity/RegistrationHandler.ts similarity index 98% rename from src/server/lib/routes/secondfactor/totp/identity/RegistrationHandler.ts rename to server/src/lib/routes/secondfactor/totp/identity/RegistrationHandler.ts index b4adee977..968a38587 100644 --- a/src/server/lib/routes/secondfactor/totp/identity/RegistrationHandler.ts +++ b/server/src/lib/routes/secondfactor/totp/identity/RegistrationHandler.ts @@ -7,7 +7,7 @@ import { Identity } from "../../../../../../types/Identity"; import { IdentityValidable } from "../../../../IdentityCheckMiddleware"; import { PRE_VALIDATION_TEMPLATE } from "../../../../IdentityCheckPreValidationTemplate"; import Constants = require("../constants"); -import Endpoints = require("../../../../../endpoints"); +import Endpoints = require("../../../../../../../shared/api"); import ErrorReplies = require("../../../../ErrorReplies"); import { ServerVariablesHandler } from "../../../../ServerVariablesHandler"; import AuthenticationSession = require("../../../../AuthenticationSession"); diff --git a/src/server/lib/routes/secondfactor/totp/sign/post.ts b/server/src/lib/routes/secondfactor/totp/sign/post.ts similarity index 96% rename from src/server/lib/routes/secondfactor/totp/sign/post.ts rename to server/src/lib/routes/secondfactor/totp/sign/post.ts index 62059249a..6e4275f6a 100644 --- a/src/server/lib/routes/secondfactor/totp/sign/post.ts +++ b/server/src/lib/routes/secondfactor/totp/sign/post.ts @@ -5,7 +5,7 @@ import express = require("express"); import { TOTPSecretDocument } from "../../../../storage/TOTPSecretDocument"; import BluebirdPromise = require("bluebird"); import FirstFactorBlocker from "../../../FirstFactorBlocker"; -import Endpoints = require("../../../../../endpoints"); +import Endpoints = require("../../../../../../../shared/api"); import redirect from "../../redirect"; import ErrorReplies = require("../../../../ErrorReplies"); import { ServerVariablesHandler } from "./../../../../ServerVariablesHandler"; diff --git a/src/server/lib/routes/secondfactor/u2f/U2FCommon.ts b/server/src/lib/routes/secondfactor/u2f/U2FCommon.ts similarity index 100% rename from src/server/lib/routes/secondfactor/u2f/U2FCommon.ts rename to server/src/lib/routes/secondfactor/u2f/U2FCommon.ts diff --git a/src/server/lib/routes/secondfactor/u2f/identity/RegistrationHandler.ts b/server/src/lib/routes/secondfactor/u2f/identity/RegistrationHandler.ts similarity index 100% rename from src/server/lib/routes/secondfactor/u2f/identity/RegistrationHandler.ts rename to server/src/lib/routes/secondfactor/u2f/identity/RegistrationHandler.ts diff --git a/src/server/lib/routes/secondfactor/u2f/register/post.ts b/server/src/lib/routes/secondfactor/u2f/register/post.ts similarity index 100% rename from src/server/lib/routes/secondfactor/u2f/register/post.ts rename to server/src/lib/routes/secondfactor/u2f/register/post.ts diff --git a/src/server/lib/routes/secondfactor/u2f/register_request/get.ts b/server/src/lib/routes/secondfactor/u2f/register_request/get.ts similarity index 100% rename from src/server/lib/routes/secondfactor/u2f/register_request/get.ts rename to server/src/lib/routes/secondfactor/u2f/register_request/get.ts diff --git a/src/server/lib/routes/secondfactor/u2f/sign/post.ts b/server/src/lib/routes/secondfactor/u2f/sign/post.ts similarity index 100% rename from src/server/lib/routes/secondfactor/u2f/sign/post.ts rename to server/src/lib/routes/secondfactor/u2f/sign/post.ts diff --git a/src/server/lib/routes/secondfactor/u2f/sign_request/get.ts b/server/src/lib/routes/secondfactor/u2f/sign_request/get.ts similarity index 97% rename from src/server/lib/routes/secondfactor/u2f/sign_request/get.ts rename to server/src/lib/routes/secondfactor/u2f/sign_request/get.ts index 0755a01ac..841927d85 100644 --- a/src/server/lib/routes/secondfactor/u2f/sign_request/get.ts +++ b/server/src/lib/routes/secondfactor/u2f/sign_request/get.ts @@ -8,7 +8,7 @@ import { UserDataStore } from "../../../../storage/UserDataStore"; import { U2FRegistrationDocument } from "../../../../storage/U2FRegistrationDocument"; import { Winston } from "../../../../../../types/Dependencies"; import exceptions = require("../../../../Exceptions"); -import { SignMessage } from "./SignMessage"; +import { SignMessage } from "../../../../../../../shared/SignMessage"; import FirstFactorBlocker from "../../../FirstFactorBlocker"; import ErrorReplies = require("../../../../ErrorReplies"); import { ServerVariablesHandler } from "../../../../ServerVariablesHandler"; diff --git a/src/server/lib/routes/verify/get.ts b/server/src/lib/routes/verify/get.ts similarity index 97% rename from src/server/lib/routes/verify/get.ts rename to server/src/lib/routes/verify/get.ts index 390b198a4..7bd59d49a 100644 --- a/src/server/lib/routes/verify/get.ts +++ b/server/src/lib/routes/verify/get.ts @@ -8,7 +8,7 @@ import AuthenticationValidator = require("../../AuthenticationValidator"); import ErrorReplies = require("../../ErrorReplies"); import { ServerVariablesHandler } from "../../ServerVariablesHandler"; import AuthenticationSession = require("../../AuthenticationSession"); -import Constants = require("../../../constants"); +import Constants = require("../../../../../shared/constants"); function verify_filter(req: express.Request, res: express.Response): BluebirdPromise { const logger = ServerVariablesHandler.getLogger(req.app); diff --git a/src/server/lib/storage/AuthenticationTraceDocument.d.ts b/server/src/lib/storage/AuthenticationTraceDocument.d.ts similarity index 100% rename from src/server/lib/storage/AuthenticationTraceDocument.d.ts rename to server/src/lib/storage/AuthenticationTraceDocument.d.ts diff --git a/src/server/lib/storage/CollectionFactoryFactory.ts b/server/src/lib/storage/CollectionFactoryFactory.ts similarity index 100% rename from src/server/lib/storage/CollectionFactoryFactory.ts rename to server/src/lib/storage/CollectionFactoryFactory.ts diff --git a/src/server/lib/storage/ICollection.d.ts b/server/src/lib/storage/ICollection.d.ts similarity index 100% rename from src/server/lib/storage/ICollection.d.ts rename to server/src/lib/storage/ICollection.d.ts diff --git a/src/server/lib/storage/ICollectionFactory.d.ts b/server/src/lib/storage/ICollectionFactory.d.ts similarity index 100% rename from src/server/lib/storage/ICollectionFactory.d.ts rename to server/src/lib/storage/ICollectionFactory.d.ts diff --git a/src/server/lib/storage/IUserDataStore.d.ts b/server/src/lib/storage/IUserDataStore.d.ts similarity index 100% rename from src/server/lib/storage/IUserDataStore.d.ts rename to server/src/lib/storage/IUserDataStore.d.ts diff --git a/src/server/lib/storage/IdentityValidationDocument.d.ts b/server/src/lib/storage/IdentityValidationDocument.d.ts similarity index 100% rename from src/server/lib/storage/IdentityValidationDocument.d.ts rename to server/src/lib/storage/IdentityValidationDocument.d.ts diff --git a/src/server/lib/storage/TOTPSecretDocument.d.ts b/server/src/lib/storage/TOTPSecretDocument.d.ts similarity index 100% rename from src/server/lib/storage/TOTPSecretDocument.d.ts rename to server/src/lib/storage/TOTPSecretDocument.d.ts diff --git a/src/server/lib/storage/U2FRegistrationDocument.d.ts b/server/src/lib/storage/U2FRegistrationDocument.d.ts similarity index 100% rename from src/server/lib/storage/U2FRegistrationDocument.d.ts rename to server/src/lib/storage/U2FRegistrationDocument.d.ts diff --git a/src/server/lib/storage/UserDataStore.ts b/server/src/lib/storage/UserDataStore.ts similarity index 100% rename from src/server/lib/storage/UserDataStore.ts rename to server/src/lib/storage/UserDataStore.ts diff --git a/src/server/lib/storage/mongo/MongoCollection.ts b/server/src/lib/storage/mongo/MongoCollection.ts similarity index 100% rename from src/server/lib/storage/mongo/MongoCollection.ts rename to server/src/lib/storage/mongo/MongoCollection.ts diff --git a/src/server/lib/storage/mongo/MongoCollectionFactory.ts b/server/src/lib/storage/mongo/MongoCollectionFactory.ts similarity index 100% rename from src/server/lib/storage/mongo/MongoCollectionFactory.ts rename to server/src/lib/storage/mongo/MongoCollectionFactory.ts diff --git a/src/server/lib/storage/nedb/NedbCollection.ts b/server/src/lib/storage/nedb/NedbCollection.ts similarity index 66% rename from src/server/lib/storage/nedb/NedbCollection.ts rename to server/src/lib/storage/nedb/NedbCollection.ts index c42ea07a7..88a93ad05 100644 --- a/src/server/lib/storage/nedb/NedbCollection.ts +++ b/server/src/lib/storage/nedb/NedbCollection.ts @@ -1,14 +1,23 @@ import BluebirdPromise = require("bluebird"); import { ICollection } from "../ICollection"; import Nedb = require("nedb"); -import { NedbAsync } from "nedb"; +declare module "nedb" { + export class NedbAsync extends Nedb { + constructor(pathOrOptions?: string | Nedb.DataStoreOptions); + updateAsync(query: any, updateQuery: any, options?: Nedb.UpdateOptions): BluebirdPromise; + findOneAsync(query: any): BluebirdPromise; + insertAsync(newDoc: T): BluebirdPromise; + removeAsync(query: any): BluebirdPromise; + countAsync(query: any): BluebirdPromise; + } +} export class NedbCollection implements ICollection { - private collection: NedbAsync; + private collection: Nedb.NedbAsync; constructor(options: Nedb.DataStoreOptions) { - this.collection = BluebirdPromise.promisifyAll(new Nedb(options)) as NedbAsync; + this.collection = BluebirdPromise.promisifyAll(new Nedb(options)) as Nedb.NedbAsync; } find(query: any, sortKeys?: any, count?: number): BluebirdPromise { diff --git a/src/server/lib/storage/nedb/NedbCollectionFactory.ts b/server/src/lib/storage/nedb/NedbCollectionFactory.ts similarity index 100% rename from src/server/lib/storage/nedb/NedbCollectionFactory.ts rename to server/src/lib/storage/nedb/NedbCollectionFactory.ts diff --git a/src/server/resources/email-template.ejs b/server/src/resources/email-template.ejs similarity index 100% rename from src/server/resources/email-template.ejs rename to server/src/resources/email-template.ejs diff --git a/src/server/views/already-logged-in.pug b/server/src/views/already-logged-in.pug similarity index 100% rename from src/server/views/already-logged-in.pug rename to server/src/views/already-logged-in.pug diff --git a/src/server/views/errors/401.pug b/server/src/views/errors/401.pug similarity index 100% rename from src/server/views/errors/401.pug rename to server/src/views/errors/401.pug diff --git a/src/server/views/errors/403.pug b/server/src/views/errors/403.pug similarity index 100% rename from src/server/views/errors/403.pug rename to server/src/views/errors/403.pug diff --git a/src/server/views/errors/404.pug b/server/src/views/errors/404.pug similarity index 100% rename from src/server/views/errors/404.pug rename to server/src/views/errors/404.pug diff --git a/src/server/views/firstfactor.pug b/server/src/views/firstfactor.pug similarity index 100% rename from src/server/views/firstfactor.pug rename to server/src/views/firstfactor.pug diff --git a/src/server/views/layout/layout.pug b/server/src/views/layout/layout.pug similarity index 100% rename from src/server/views/layout/layout.pug rename to server/src/views/layout/layout.pug diff --git a/src/server/views/need-identity-validation.pug b/server/src/views/need-identity-validation.pug similarity index 100% rename from src/server/views/need-identity-validation.pug rename to server/src/views/need-identity-validation.pug diff --git a/src/server/views/password-reset-form.pug b/server/src/views/password-reset-form.pug similarity index 100% rename from src/server/views/password-reset-form.pug rename to server/src/views/password-reset-form.pug diff --git a/src/server/views/password-reset-request.pug b/server/src/views/password-reset-request.pug similarity index 100% rename from src/server/views/password-reset-request.pug rename to server/src/views/password-reset-request.pug diff --git a/src/server/views/secondfactor.pug b/server/src/views/secondfactor.pug similarity index 100% rename from src/server/views/secondfactor.pug rename to server/src/views/secondfactor.pug diff --git a/src/server/views/totp-register.pug b/server/src/views/totp-register.pug similarity index 100% rename from src/server/views/totp-register.pug rename to server/src/views/totp-register.pug diff --git a/src/server/views/u2f-register.pug b/server/src/views/u2f-register.pug similarity index 100% rename from src/server/views/u2f-register.pug rename to server/src/views/u2f-register.pug diff --git a/test/unit/server/AuthenticationRegulator.test.ts b/server/test/AuthenticationRegulator.test.ts similarity index 97% rename from test/unit/server/AuthenticationRegulator.test.ts rename to server/test/AuthenticationRegulator.test.ts index 7f2c3aff2..f3e40aa2d 100644 --- a/test/unit/server/AuthenticationRegulator.test.ts +++ b/server/test/AuthenticationRegulator.test.ts @@ -3,9 +3,9 @@ import Sinon = require("sinon"); import BluebirdPromise = require("bluebird"); import Assert = require("assert"); -import { AuthenticationRegulator } from "../../../src/server/lib/AuthenticationRegulator"; +import { AuthenticationRegulator } from "../src/lib/AuthenticationRegulator"; import MockDate = require("mockdate"); -import exceptions = require("../../../src/server/lib/Exceptions"); +import exceptions = require("../src/lib/Exceptions"); import { UserDataStoreStub } from "./mocks/storage/UserDataStoreStub"; describe("test authentication regulator", function () { diff --git a/test/unit/server/IdentityCheckMiddleware.test.ts b/server/test/IdentityCheckMiddleware.test.ts similarity index 95% rename from test/unit/server/IdentityCheckMiddleware.test.ts rename to server/test/IdentityCheckMiddleware.test.ts index d187c9980..37388c3e6 100644 --- a/test/unit/server/IdentityCheckMiddleware.test.ts +++ b/server/test/IdentityCheckMiddleware.test.ts @@ -1,10 +1,10 @@ import sinon = require("sinon"); -import IdentityValidator = require("../../../src/server/lib/IdentityCheckMiddleware"); -import AuthenticationSession = require("../../../src/server/lib/AuthenticationSession"); -import { UserDataStore } from "../../../src/server/lib/storage/UserDataStore"; +import IdentityValidator = require("../src/lib/IdentityCheckMiddleware"); +import AuthenticationSession = require("../src/lib/AuthenticationSession"); +import { UserDataStore } from "../src/lib/storage/UserDataStore"; -import exceptions = require("../../../src/server/lib/Exceptions"); +import exceptions = require("../src/lib/Exceptions"); import assert = require("assert"); import Promise = require("bluebird"); import express = require("express"); diff --git a/test/unit/server/ServerConfiguration.test.ts b/server/test/ServerConfiguration.test.ts similarity index 89% rename from test/unit/server/ServerConfiguration.test.ts rename to server/test/ServerConfiguration.test.ts index cbc9d7eaa..338d16bff 100644 --- a/test/unit/server/ServerConfiguration.test.ts +++ b/server/test/ServerConfiguration.test.ts @@ -9,9 +9,9 @@ import u2f = require("u2f"); import nodemailer = require("nodemailer"); import session = require("express-session"); -import { AppConfiguration, UserConfiguration } from "../../../src/server/lib/configuration/Configuration"; -import { GlobalDependencies, Nodemailer } from "../../../src/types/Dependencies"; -import Server from "../../../src/server/lib/Server"; +import { AppConfiguration, UserConfiguration } from "../src/lib/configuration/Configuration"; +import { GlobalDependencies, Nodemailer } from "../types/Dependencies"; +import Server from "../src/lib/Server"; describe("test server configuration", function () { diff --git a/test/unit/server/SessionConfigurationBuilder.test.ts b/server/test/SessionConfigurationBuilder.test.ts similarity index 94% rename from test/unit/server/SessionConfigurationBuilder.test.ts rename to server/test/SessionConfigurationBuilder.test.ts index 69882b23d..0884d8ee1 100644 --- a/test/unit/server/SessionConfigurationBuilder.test.ts +++ b/server/test/SessionConfigurationBuilder.test.ts @@ -1,6 +1,6 @@ -import { SessionConfigurationBuilder } from "../../../src/server/lib/configuration/SessionConfigurationBuilder"; -import { AppConfiguration } from "../../../src/server/lib/configuration/Configuration"; -import { GlobalDependencies } from "../../../src/types/Dependencies"; +import { SessionConfigurationBuilder } from "../src/lib/configuration/SessionConfigurationBuilder"; +import { AppConfiguration } from "../src/lib/configuration/Configuration"; +import { GlobalDependencies } from "../types/Dependencies"; import ExpressSession = require("express-session"); import ConnectRedis = require("connect-redis"); diff --git a/test/unit/server/TOTPValidator.test.ts b/server/test/TOTPValidator.test.ts similarity index 91% rename from test/unit/server/TOTPValidator.test.ts rename to server/test/TOTPValidator.test.ts index 0ef3faf51..6fd3981f0 100644 --- a/test/unit/server/TOTPValidator.test.ts +++ b/server/test/TOTPValidator.test.ts @@ -1,5 +1,5 @@ -import { TOTPValidator } from "../../../src/server/lib/TOTPValidator"; +import { TOTPValidator } from "../src/lib/TOTPValidator"; import sinon = require("sinon"); import Promise = require("bluebird"); import SpeakeasyMock = require("./mocks/speakeasy"); diff --git a/test/unit/server/access_control/AccessController.test.ts b/server/test/access_control/AccessController.test.ts similarity index 98% rename from test/unit/server/access_control/AccessController.test.ts rename to server/test/access_control/AccessController.test.ts index 97c91fcd3..aca3ee3ee 100644 --- a/test/unit/server/access_control/AccessController.test.ts +++ b/server/test/access_control/AccessController.test.ts @@ -1,8 +1,8 @@ import Assert = require("assert"); import winston = require("winston"); -import { AccessController } from "../../../../src/server/lib/access_control/AccessController"; -import { ACLConfiguration, ACLRule } from "../../../../src/server/lib/configuration/Configuration"; +import { AccessController } from "../../src/lib/access_control/AccessController"; +import { ACLConfiguration, ACLRule } from "../../src/lib/configuration/Configuration"; describe("test access control manager", function () { let accessController: AccessController; diff --git a/test/unit/server/configuration/ConfigurationAdapter.test.ts b/server/test/configuration/ConfigurationAdapter.test.ts similarity index 94% rename from test/unit/server/configuration/ConfigurationAdapter.test.ts rename to server/test/configuration/ConfigurationAdapter.test.ts index d7886e8c7..100a5e182 100644 --- a/test/unit/server/configuration/ConfigurationAdapter.test.ts +++ b/server/test/configuration/ConfigurationAdapter.test.ts @@ -2,8 +2,8 @@ import * as Assert from "assert"; import { UserConfiguration, LdapConfiguration, ACLConfiguration -} from "../../../../src/server/lib/configuration/Configuration"; -import { ConfigurationAdapter } from "../../../../src/server/lib/configuration/ConfigurationAdapter"; +} from "../../src/lib/configuration/Configuration"; +import { ConfigurationAdapter } from "../../src/lib/configuration/ConfigurationAdapter"; describe("test config adapter", function () { function build_yaml_config(): UserConfiguration { diff --git a/test/unit/server/configuration/LdapConfigurationAdaptation.test.ts b/server/test/configuration/LdapConfigurationAdaptation.test.ts similarity index 92% rename from test/unit/server/configuration/LdapConfigurationAdaptation.test.ts rename to server/test/configuration/LdapConfigurationAdaptation.test.ts index 0bf8df29d..42c84d851 100644 --- a/test/unit/server/configuration/LdapConfigurationAdaptation.test.ts +++ b/server/test/configuration/LdapConfigurationAdaptation.test.ts @@ -1,6 +1,6 @@ import * as Assert from "assert"; -import { UserConfiguration, LdapConfiguration } from "../../../../src/server/lib/configuration/Configuration"; -import { ConfigurationAdapter } from "../../../../src/server/lib/configuration/ConfigurationAdapter"; +import { UserConfiguration, LdapConfiguration } from "../../src/lib/configuration/Configuration"; +import { ConfigurationAdapter } from "../../src/lib/configuration/ConfigurationAdapter"; describe("test ldap configuration adaptation", function () { function build_yaml_config(): UserConfiguration { diff --git a/test/unit/server/connectors/mongo/MongoClient.test.ts b/server/test/connectors/mongo/MongoClient.test.ts similarity index 92% rename from test/unit/server/connectors/mongo/MongoClient.test.ts rename to server/test/connectors/mongo/MongoClient.test.ts index c3f9a2543..37ad0c4d6 100644 --- a/test/unit/server/connectors/mongo/MongoClient.test.ts +++ b/server/test/connectors/mongo/MongoClient.test.ts @@ -1,7 +1,7 @@ import Assert = require("assert"); import Sinon = require("sinon"); import MongoDB = require("mongodb"); -import { MongoClient } from "../../../../../src/server/lib/connectors/mongo/MongoClient"; +import { MongoClient } from "../../../src/lib/connectors/mongo/MongoClient"; describe("MongoClient", function () { let mongoClientConnectStub: Sinon.SinonStub; diff --git a/test/unit/server/connectors/mongo/MongoConnector.test.ts b/server/test/connectors/mongo/MongoConnector.test.ts similarity index 88% rename from test/unit/server/connectors/mongo/MongoConnector.test.ts rename to server/test/connectors/mongo/MongoConnector.test.ts index 1bc24d4b4..072bcd83a 100644 --- a/test/unit/server/connectors/mongo/MongoConnector.test.ts +++ b/server/test/connectors/mongo/MongoConnector.test.ts @@ -2,8 +2,8 @@ import Assert = require("assert"); import Sinon = require("sinon"); import MongoDB = require("mongodb"); import BluebirdPromise = require("bluebird"); -import { IMongoClient } from "../../../../../src/server/lib/connectors/mongo/IMongoClient"; -import { MongoConnector } from "../../../../../src/server/lib/connectors/mongo/MongoConnector"; +import { IMongoClient } from "../../../src/lib/connectors/mongo/IMongoClient"; +import { MongoConnector } from "../../../src/lib/connectors/mongo/MongoConnector"; describe("MongoConnector", function () { let mongoClientConnectStub: Sinon.SinonStub; diff --git a/test/unit/server/connectors/mongo/MongoConnectorFactory.test.ts b/server/test/connectors/mongo/MongoConnectorFactory.test.ts similarity index 74% rename from test/unit/server/connectors/mongo/MongoConnectorFactory.test.ts rename to server/test/connectors/mongo/MongoConnectorFactory.test.ts index 2428507c8..9d5d9cab4 100644 --- a/test/unit/server/connectors/mongo/MongoConnectorFactory.test.ts +++ b/server/test/connectors/mongo/MongoConnectorFactory.test.ts @@ -1,5 +1,5 @@ import Assert = require("assert"); -import { MongoConnectorFactory } from "../../../../../src/server/lib/connectors/mongo/MongoConnectorFactory"; +import { MongoConnectorFactory } from "../../../src/lib/connectors/mongo/MongoConnectorFactory"; describe("MongoConnectorFactory", function () { describe("create", function () { diff --git a/test/unit/server/ldap/Authenticator.test.ts b/server/test/ldap/Authenticator.test.ts similarity index 96% rename from test/unit/server/ldap/Authenticator.test.ts rename to server/test/ldap/Authenticator.test.ts index 08373d4c3..82373389e 100644 --- a/test/unit/server/ldap/Authenticator.test.ts +++ b/server/test/ldap/Authenticator.test.ts @@ -1,6 +1,6 @@ -import { Authenticator } from "../../../../src/server/lib/ldap/Authenticator"; -import { LdapConfiguration } from "../../../../src/server/lib/configuration/Configuration"; +import { Authenticator } from "../../src/lib/ldap/Authenticator"; +import { LdapConfiguration } from "../../src/lib/configuration/Configuration"; import Sinon = require("sinon"); import BluebirdPromise = require("bluebird"); diff --git a/test/unit/server/ldap/EmailsRetriever.test.ts b/server/test/ldap/EmailsRetriever.test.ts similarity index 93% rename from test/unit/server/ldap/EmailsRetriever.test.ts rename to server/test/ldap/EmailsRetriever.test.ts index 2cfb7ad17..2826c4625 100644 --- a/test/unit/server/ldap/EmailsRetriever.test.ts +++ b/server/test/ldap/EmailsRetriever.test.ts @@ -1,6 +1,6 @@ -import { EmailsRetriever } from "../../../../src/server/lib/ldap/EmailsRetriever"; -import { LdapConfiguration } from "../../../../src/server/lib/configuration/Configuration"; +import { EmailsRetriever } from "../../src/lib/ldap/EmailsRetriever"; +import { LdapConfiguration } from "../../src/lib/configuration/Configuration"; import Sinon = require("sinon"); import BluebirdPromise = require("bluebird"); diff --git a/test/unit/server/ldap/PasswordUpdater.test.ts b/server/test/ldap/PasswordUpdater.test.ts similarity index 93% rename from test/unit/server/ldap/PasswordUpdater.test.ts rename to server/test/ldap/PasswordUpdater.test.ts index 514bf6011..634b22f16 100644 --- a/test/unit/server/ldap/PasswordUpdater.test.ts +++ b/server/test/ldap/PasswordUpdater.test.ts @@ -1,6 +1,6 @@ -import { PasswordUpdater } from "../../../../src/server/lib/ldap/PasswordUpdater"; -import { LdapConfiguration } from "../../../../src/server/lib/configuration/Configuration"; +import { PasswordUpdater } from "../../src/lib/ldap/PasswordUpdater"; +import { LdapConfiguration } from "../../src/lib/configuration/Configuration"; import Sinon = require("sinon"); import BluebirdPromise = require("bluebird"); diff --git a/test/unit/server/mocks/AccessControllerStub.ts b/server/test/mocks/AccessControllerStub.ts similarity index 79% rename from test/unit/server/mocks/AccessControllerStub.ts rename to server/test/mocks/AccessControllerStub.ts index 6d402e73e..e295cdab9 100644 --- a/test/unit/server/mocks/AccessControllerStub.ts +++ b/server/test/mocks/AccessControllerStub.ts @@ -1,6 +1,6 @@ import Sinon = require("sinon"); -import { IAccessController } from "../../../../src/server/lib/access_control/IAccessController"; +import { IAccessController } from "../../src/lib/access_control/IAccessController"; export class AccessControllerStub implements IAccessController { isAccessAllowedMock: Sinon.SinonStub; diff --git a/test/unit/server/mocks/AuthenticationRegulator.ts b/server/test/mocks/AuthenticationRegulator.ts similarity index 100% rename from test/unit/server/mocks/AuthenticationRegulator.ts rename to server/test/mocks/AuthenticationRegulator.ts diff --git a/test/unit/server/mocks/IdentityValidator.ts b/server/test/mocks/IdentityValidator.ts similarity index 86% rename from test/unit/server/mocks/IdentityValidator.ts rename to server/test/mocks/IdentityValidator.ts index 24898fc9f..3fbe44dc3 100644 --- a/test/unit/server/mocks/IdentityValidator.ts +++ b/server/test/mocks/IdentityValidator.ts @@ -1,9 +1,9 @@ import sinon = require("sinon"); -import { IdentityValidable } from "../../../../src/server/lib/IdentityCheckMiddleware"; +import { IdentityValidable } from "../../src/lib/IdentityCheckMiddleware"; import express = require("express"); import BluebirdPromise = require("bluebird"); -import { Identity } from "../../../../src/types/Identity"; +import { Identity } from "../../types/Identity"; export interface IdentityValidableMock { diff --git a/test/unit/server/mocks/Notifier.ts b/server/test/mocks/Notifier.ts similarity index 100% rename from test/unit/server/mocks/Notifier.ts rename to server/test/mocks/Notifier.ts diff --git a/test/unit/server/mocks/ServerVariablesMock.ts b/server/test/mocks/ServerVariablesMock.ts similarity index 92% rename from test/unit/server/mocks/ServerVariablesMock.ts rename to server/test/mocks/ServerVariablesMock.ts index ea3cdc8fe..08caf776f 100644 --- a/test/unit/server/mocks/ServerVariablesMock.ts +++ b/server/test/mocks/ServerVariablesMock.ts @@ -2,7 +2,7 @@ import Sinon = require("sinon"); import express = require("express"); import winston = require("winston"); import { UserDataStoreStub } from "./storage/UserDataStoreStub"; -import { VARIABLES_KEY } from "../../../../src/server/lib/ServerVariablesHandler"; +import { VARIABLES_KEY } from "../../src/lib/ServerVariablesHandler"; export interface ServerVariablesMock { logger: any; diff --git a/test/unit/server/mocks/TOTPValidator.ts b/server/test/mocks/TOTPValidator.ts similarity index 100% rename from test/unit/server/mocks/TOTPValidator.ts rename to server/test/mocks/TOTPValidator.ts diff --git a/test/unit/server/mocks/connectors/mongo/MongoClientStub.ts b/server/test/mocks/connectors/mongo/MongoClientStub.ts similarity index 77% rename from test/unit/server/mocks/connectors/mongo/MongoClientStub.ts rename to server/test/mocks/connectors/mongo/MongoClientStub.ts index 2ee4d0639..81999b00e 100644 --- a/test/unit/server/mocks/connectors/mongo/MongoClientStub.ts +++ b/server/test/mocks/connectors/mongo/MongoClientStub.ts @@ -1,6 +1,6 @@ import Sinon = require("sinon"); import MongoDB = require("mongodb"); -import { IMongoClient } from "../../../../../../src/server/lib/connectors/mongo/IMongoClient"; +import { IMongoClient } from "../../../../src/lib/connectors/mongo/IMongoClient"; export class MongoClientStub implements IMongoClient { public collectionStub: Sinon.SinonStub; diff --git a/test/unit/server/mocks/express.ts b/server/test/mocks/express.ts similarity index 100% rename from test/unit/server/mocks/express.ts rename to server/test/mocks/express.ts diff --git a/test/unit/server/mocks/ldap/ClientFactoryStub.ts b/server/test/mocks/ldap/ClientFactoryStub.ts similarity index 65% rename from test/unit/server/mocks/ldap/ClientFactoryStub.ts rename to server/test/mocks/ldap/ClientFactoryStub.ts index 26d3909ef..2b3afe8eb 100644 --- a/test/unit/server/mocks/ldap/ClientFactoryStub.ts +++ b/server/test/mocks/ldap/ClientFactoryStub.ts @@ -1,6 +1,6 @@ -import { IClient } from "../../../../../src/server/lib/ldap/IClient"; -import { IClientFactory } from "../../../../../src/server/lib/ldap/IClientFactory"; +import { IClient } from "../../../src/lib/ldap/IClient"; +import { IClientFactory } from "../../../src/lib/ldap/IClientFactory"; import Sinon = require("sinon"); export class ClientFactoryStub implements IClientFactory { diff --git a/test/unit/server/mocks/ldap/ClientStub.ts b/server/test/mocks/ldap/ClientStub.ts similarity index 93% rename from test/unit/server/mocks/ldap/ClientStub.ts rename to server/test/mocks/ldap/ClientStub.ts index faf3b74a0..bcfdc2aed 100644 --- a/test/unit/server/mocks/ldap/ClientStub.ts +++ b/server/test/mocks/ldap/ClientStub.ts @@ -1,6 +1,6 @@ import BluebirdPromise = require("bluebird"); -import { IClient, GroupsAndEmails } from "../../../../../src/server/lib/ldap/IClient"; +import { IClient, GroupsAndEmails } from "../../../src/lib/ldap/IClient"; import Sinon = require("sinon"); export class ClientStub implements IClient { diff --git a/test/unit/server/mocks/ldapjs.ts b/server/test/mocks/ldapjs.ts similarity index 100% rename from test/unit/server/mocks/ldapjs.ts rename to server/test/mocks/ldapjs.ts diff --git a/test/unit/server/mocks/nodemailer.ts b/server/test/mocks/nodemailer.ts similarity index 100% rename from test/unit/server/mocks/nodemailer.ts rename to server/test/mocks/nodemailer.ts diff --git a/test/unit/server/mocks/speakeasy.ts b/server/test/mocks/speakeasy.ts similarity index 100% rename from test/unit/server/mocks/speakeasy.ts rename to server/test/mocks/speakeasy.ts diff --git a/test/unit/server/mocks/storage/CollectionFactoryStub.ts b/server/test/mocks/storage/CollectionFactoryStub.ts similarity index 66% rename from test/unit/server/mocks/storage/CollectionFactoryStub.ts rename to server/test/mocks/storage/CollectionFactoryStub.ts index 74936b28b..947be55f5 100644 --- a/test/unit/server/mocks/storage/CollectionFactoryStub.ts +++ b/server/test/mocks/storage/CollectionFactoryStub.ts @@ -1,7 +1,7 @@ import BluebirdPromise = require("bluebird"); import Sinon = require("sinon"); -import { ICollection } from "../../../../../src/server/lib/storage/ICollection"; -import { ICollectionFactory } from "../../../../../src/server/lib/storage/ICollectionFactory"; +import { ICollection } from "../../../src/lib/storage/ICollection"; +import { ICollectionFactory } from "../../../src/lib/storage/ICollectionFactory"; export class CollectionFactoryStub implements ICollectionFactory { buildStub: Sinon.SinonStub; diff --git a/test/unit/server/mocks/storage/CollectionStub.ts b/server/test/mocks/storage/CollectionStub.ts similarity index 93% rename from test/unit/server/mocks/storage/CollectionStub.ts rename to server/test/mocks/storage/CollectionStub.ts index 6b83267f7..05dc76ba6 100644 --- a/test/unit/server/mocks/storage/CollectionStub.ts +++ b/server/test/mocks/storage/CollectionStub.ts @@ -1,6 +1,6 @@ import BluebirdPromise = require("bluebird"); import Sinon = require("sinon"); -import { ICollection } from "../../../../../src/server/lib/storage/ICollection"; +import { ICollection } from "../../../src/lib/storage/ICollection"; export class CollectionStub implements ICollection { findStub: Sinon.SinonStub; diff --git a/test/unit/server/mocks/storage/UserDataStoreStub.ts b/server/test/mocks/storage/UserDataStoreStub.ts similarity index 79% rename from test/unit/server/mocks/storage/UserDataStoreStub.ts rename to server/test/mocks/storage/UserDataStoreStub.ts index cb709c4fd..41fa0bb97 100644 --- a/test/unit/server/mocks/storage/UserDataStoreStub.ts +++ b/server/test/mocks/storage/UserDataStoreStub.ts @@ -1,14 +1,14 @@ import Sinon = require("sinon"); import BluebirdPromise = require("bluebird"); -import { TOTPSecretDocument } from "../../../../../src/server/lib/storage/TOTPSecretDocument"; -import { U2FRegistrationDocument } from "../../../../../src/server/lib/storage/U2FRegistrationDocument"; -import { U2FRegistration } from "../../../../../src/types/U2FRegistration"; -import { TOTPSecret } from "../../../../../src/types/TOTPSecret"; -import { AuthenticationTraceDocument } from "../../../../../src/server/lib/storage/AuthenticationTraceDocument"; -import { IdentityValidationDocument } from "../../../../../src/server/lib/storage/IdentityValidationDocument"; +import { TOTPSecretDocument } from "../../../src/lib/storage/TOTPSecretDocument"; +import { U2FRegistrationDocument } from "../../../src/lib/storage/U2FRegistrationDocument"; +import { U2FRegistration } from "../../../types/U2FRegistration"; +import { TOTPSecret } from "../../../types/TOTPSecret"; +import { AuthenticationTraceDocument } from "../../../src/lib/storage/AuthenticationTraceDocument"; +import { IdentityValidationDocument } from "../../../src/lib/storage/IdentityValidationDocument"; -import { IUserDataStore } from "../../../../../src/server/lib/storage/IUserDataStore"; +import { IUserDataStore } from "../../../src/lib/storage/IUserDataStore"; export class UserDataStoreStub implements IUserDataStore { saveU2FRegistrationStub: Sinon.SinonStub; diff --git a/test/unit/server/mocks/u2f.ts b/server/test/mocks/u2f.ts similarity index 100% rename from test/unit/server/mocks/u2f.ts rename to server/test/mocks/u2f.ts diff --git a/test/unit/server/notifiers/GMailNotifier.test.ts b/server/test/notifiers/GMailNotifier.test.ts similarity index 93% rename from test/unit/server/notifiers/GMailNotifier.test.ts rename to server/test/notifiers/GMailNotifier.test.ts index 08b6a112e..d7c5828e2 100644 --- a/test/unit/server/notifiers/GMailNotifier.test.ts +++ b/server/test/notifiers/GMailNotifier.test.ts @@ -3,7 +3,7 @@ import * as assert from "assert"; import BluebirdPromise = require("bluebird"); import NodemailerMock = require("../mocks/nodemailer"); -import GMailNotifier = require("../../../../src/server/lib/notifiers/GMailNotifier"); +import GMailNotifier = require("../../src/lib/notifiers/GMailNotifier"); describe("test gmail notifier", function () { diff --git a/test/unit/server/notifiers/NotifierFactory.test.ts b/server/test/notifiers/NotifierFactory.test.ts similarity index 82% rename from test/unit/server/notifiers/NotifierFactory.test.ts rename to server/test/notifiers/NotifierFactory.test.ts index a28034b06..191432777 100644 --- a/test/unit/server/notifiers/NotifierFactory.test.ts +++ b/server/test/notifiers/NotifierFactory.test.ts @@ -3,9 +3,9 @@ import * as sinon from "sinon"; import * as BluebirdPromise from "bluebird"; import * as assert from "assert"; -import { NotifierFactory } from "../../../../src/server/lib/notifiers/NotifierFactory"; -import { GMailNotifier } from "../../../../src/server/lib/notifiers/GMailNotifier"; -import { SmtpNotifier } from "../../../../src/server/lib/notifiers/SmtpNotifier"; +import { NotifierFactory } from "../../src/lib/notifiers/NotifierFactory"; +import { GMailNotifier } from "../../src/lib/notifiers/GMailNotifier"; +import { SmtpNotifier } from "../../src/lib/notifiers/SmtpNotifier"; import NodemailerMock = require("../mocks/nodemailer"); diff --git a/test/unit/server/requests.ts b/server/test/requests.ts similarity index 89% rename from test/unit/server/requests.ts rename to server/test/requests.ts index 557cf909e..268556f52 100644 --- a/test/unit/server/requests.ts +++ b/server/test/requests.ts @@ -4,10 +4,24 @@ import request = require("request"); import assert = require("assert"); import express = require("express"); import nodemailer = require("nodemailer"); -import Endpoints = require("../../../src/server/endpoints"); +import Endpoints = require("../../shared/api"); import NodemailerMock = require("./mocks/nodemailer"); +declare module "request" { + export interface RequestAPI { + getAsync(uri: string, options?: RequiredUriUrl): BluebirdPromise; + getAsync(uri: string): BluebirdPromise; + getAsync(options: RequiredUriUrl & CoreOptions): BluebirdPromise; + + postAsync(uri: string, options?: CoreOptions): BluebirdPromise; + postAsync(uri: string): BluebirdPromise; + postAsync(options: RequiredUriUrl & CoreOptions): BluebirdPromise; + } +} + const requestAsync: typeof request = BluebirdPromise.promisifyAll(request) as typeof request; export = function (port: number) { diff --git a/test/unit/server/routes/errors/401/get.test.ts b/server/test/routes/errors/401/get.test.ts similarity index 85% rename from test/unit/server/routes/errors/401/get.test.ts rename to server/test/routes/errors/401/get.test.ts index 2728cb1f5..721622856 100644 --- a/test/unit/server/routes/errors/401/get.test.ts +++ b/server/test/routes/errors/401/get.test.ts @@ -1,7 +1,7 @@ import Sinon = require("sinon"); import Express = require("express"); import Assert = require("assert"); -import Get401 from "../../../../../../src/server/lib/routes/error/401/get"; +import Get401 from "../../../../src/lib/routes/error/401/get"; describe("Server error 401", function () { it("should render the page", function () { diff --git a/test/unit/server/routes/errors/403/get.test.ts b/server/test/routes/errors/403/get.test.ts similarity index 85% rename from test/unit/server/routes/errors/403/get.test.ts rename to server/test/routes/errors/403/get.test.ts index b3b78721b..09f141e3f 100644 --- a/test/unit/server/routes/errors/403/get.test.ts +++ b/server/test/routes/errors/403/get.test.ts @@ -1,7 +1,7 @@ import Sinon = require("sinon"); import Express = require("express"); import Assert = require("assert"); -import Get403 from "../../../../../../src/server/lib/routes/error/403/get"; +import Get403 from "../../../../src/lib/routes/error/403/get"; describe("Server error 403", function () { it("should render the page", function () { diff --git a/test/unit/server/routes/errors/404/get.test.ts b/server/test/routes/errors/404/get.test.ts similarity index 85% rename from test/unit/server/routes/errors/404/get.test.ts rename to server/test/routes/errors/404/get.test.ts index fe20a4d13..fe2838605 100644 --- a/test/unit/server/routes/errors/404/get.test.ts +++ b/server/test/routes/errors/404/get.test.ts @@ -1,7 +1,7 @@ import Sinon = require("sinon"); import Express = require("express"); import Assert = require("assert"); -import Get404 from "../../../../../../src/server/lib/routes/error/404/get"; +import Get404 from "../../../../src/lib/routes/error/404/get"; describe("Server error 404", function () { it("should render the page", function () { diff --git a/test/unit/server/routes/firstfactor/post.test.ts b/server/test/routes/firstfactor/post.test.ts similarity index 92% rename from test/unit/server/routes/firstfactor/post.test.ts rename to server/test/routes/firstfactor/post.test.ts index b5329b046..c7c1c866a 100644 --- a/test/unit/server/routes/firstfactor/post.test.ts +++ b/server/test/routes/firstfactor/post.test.ts @@ -4,16 +4,16 @@ import BluebirdPromise = require("bluebird"); import assert = require("assert"); import winston = require("winston"); -import FirstFactorPost = require("../../../../../src/server/lib/routes/firstfactor/post"); -import exceptions = require("../../../../../src/server/lib/Exceptions"); -import AuthenticationSession = require("../../../../../src/server/lib/AuthenticationSession"); -import Endpoints = require("../../../../../src/server/endpoints"); +import FirstFactorPost = require("../../../src/lib/routes/firstfactor/post"); +import exceptions = require("../../../src/lib/Exceptions"); +import AuthenticationSession = require("../../../src/lib/AuthenticationSession"); +import Endpoints = require("../../../../shared/api"); import AuthenticationRegulatorMock = require("../../mocks/AuthenticationRegulator"); import { AccessControllerStub } from "../../mocks/AccessControllerStub"; import ExpressMock = require("../../mocks/express"); import ServerVariablesMock = require("../../mocks/ServerVariablesMock"); -import { ServerVariables } from "../../../../../src/server/lib/ServerVariablesHandler"; +import { ServerVariables } from "../../../src/lib/ServerVariablesHandler"; describe("test the first factor validation route", function () { let req: ExpressMock.RequestMock; diff --git a/test/unit/server/routes/password-reset/identity/PasswordResetHandler.test.ts b/server/test/routes/password-reset/identity/PasswordResetHandler.test.ts similarity index 90% rename from test/unit/server/routes/password-reset/identity/PasswordResetHandler.test.ts rename to server/test/routes/password-reset/identity/PasswordResetHandler.test.ts index 512a0eff4..74e761162 100644 --- a/test/unit/server/routes/password-reset/identity/PasswordResetHandler.test.ts +++ b/server/test/routes/password-reset/identity/PasswordResetHandler.test.ts @@ -1,8 +1,8 @@ -import PasswordResetHandler from "../../../../../../src/server/lib/routes/password-reset/identity/PasswordResetHandler"; -import PasswordUpdater = require("../../../../../../src/server/lib/ldap/PasswordUpdater"); -import { ServerVariablesHandler } from "../../../../../../src/server/lib/ServerVariablesHandler"; -import { UserDataStore } from "../../../../../../src/server/lib/storage/UserDataStore"; +import PasswordResetHandler from "../../../../src/lib/routes/password-reset/identity/PasswordResetHandler"; +import PasswordUpdater = require("../../../../src/lib/ldap/PasswordUpdater"); +import { ServerVariablesHandler } from "../../../../src/lib/ServerVariablesHandler"; +import { UserDataStore } from "../../../../src/lib/storage/UserDataStore"; import Sinon = require("sinon"); import winston = require("winston"); import assert = require("assert"); diff --git a/test/unit/server/routes/password-reset/post.test.ts b/server/test/routes/password-reset/post.test.ts similarity index 89% rename from test/unit/server/routes/password-reset/post.test.ts rename to server/test/routes/password-reset/post.test.ts index 71a2cf505..920f97d27 100644 --- a/test/unit/server/routes/password-reset/post.test.ts +++ b/server/test/routes/password-reset/post.test.ts @@ -1,9 +1,9 @@ -import PasswordResetFormPost = require("../../../../../src/server/lib/routes/password-reset/form/post"); -import { PasswordUpdater } from "../../../../../src/server/lib/ldap/PasswordUpdater"; -import AuthenticationSession = require("../../../../../src/server/lib/AuthenticationSession"); -import { ServerVariablesHandler } from "../../../../../src/server/lib/ServerVariablesHandler"; -import { UserDataStore } from "../../../../../src/server/lib/storage/UserDataStore"; +import PasswordResetFormPost = require("../../../src/lib/routes/password-reset/form/post"); +import { PasswordUpdater } from "../../../src/lib/ldap/PasswordUpdater"; +import AuthenticationSession = require("../../../src/lib/AuthenticationSession"); +import { ServerVariablesHandler } from "../../../src/lib/ServerVariablesHandler"; +import { UserDataStore } from "../../../src/lib/storage/UserDataStore"; import Sinon = require("sinon"); import winston = require("winston"); import assert = require("assert"); diff --git a/test/unit/server/routes/secondfactor/totp/register/RegistrationHandler.test.ts b/server/test/routes/secondfactor/totp/register/RegistrationHandler.test.ts similarity index 88% rename from test/unit/server/routes/secondfactor/totp/register/RegistrationHandler.test.ts rename to server/test/routes/secondfactor/totp/register/RegistrationHandler.test.ts index cf13f90bc..a913b1a4c 100644 --- a/test/unit/server/routes/secondfactor/totp/register/RegistrationHandler.test.ts +++ b/server/test/routes/secondfactor/totp/register/RegistrationHandler.test.ts @@ -1,9 +1,9 @@ import Sinon = require("sinon"); import winston = require("winston"); -import RegistrationHandler from "../../../../../../../src/server/lib/routes/secondfactor/totp/identity/RegistrationHandler"; -import { Identity } from "../../../../../../../src/types/Identity"; -import AuthenticationSession = require("../../../../../../../src/server/lib/AuthenticationSession"); -import { UserDataStore } from "../../../../../../../src/server/lib/storage/UserDataStore"; +import RegistrationHandler from "../../../../../src/lib/routes/secondfactor/totp/identity/RegistrationHandler"; +import { Identity } from "../../../../../types/Identity"; +import AuthenticationSession = require("../../../../../src/lib/AuthenticationSession"); +import { UserDataStore } from "../../../../../src/lib/storage/UserDataStore"; import assert = require("assert"); import BluebirdPromise = require("bluebird"); diff --git a/test/unit/server/routes/secondfactor/totp/sign/post.test.ts b/server/test/routes/secondfactor/totp/sign/post.test.ts similarity index 91% rename from test/unit/server/routes/secondfactor/totp/sign/post.test.ts rename to server/test/routes/secondfactor/totp/sign/post.test.ts index b7ce7a132..a562d1ba2 100644 --- a/test/unit/server/routes/secondfactor/totp/sign/post.test.ts +++ b/server/test/routes/secondfactor/totp/sign/post.test.ts @@ -4,9 +4,9 @@ import sinon = require("sinon"); import assert = require("assert"); import winston = require("winston"); -import exceptions = require("../../../../../../../src/server/lib/Exceptions"); -import AuthenticationSession = require("../../../../../../../src/server/lib/AuthenticationSession"); -import SignPost = require("../../../../../../../src/server/lib/routes/secondfactor/totp/sign/post"); +import exceptions = require("../../../../../src/lib/Exceptions"); +import AuthenticationSession = require("../../../../../src/lib/AuthenticationSession"); +import SignPost = require("../../../../../src/lib/routes/secondfactor/totp/sign/post"); import ExpressMock = require("../../../../mocks/express"); import TOTPValidatorMock = require("../../../../mocks/TOTPValidator"); diff --git a/test/unit/server/routes/secondfactor/u2f/identity/RegistrationHandler.test.ts b/server/test/routes/secondfactor/u2f/identity/RegistrationHandler.test.ts similarity index 91% rename from test/unit/server/routes/secondfactor/u2f/identity/RegistrationHandler.test.ts rename to server/test/routes/secondfactor/u2f/identity/RegistrationHandler.test.ts index 859b614ef..11d28eb03 100644 --- a/test/unit/server/routes/secondfactor/u2f/identity/RegistrationHandler.test.ts +++ b/server/test/routes/secondfactor/u2f/identity/RegistrationHandler.test.ts @@ -3,9 +3,9 @@ import winston = require("winston"); import assert = require("assert"); import BluebirdPromise = require("bluebird"); -import { Identity } from "../../../../../../../src/types/Identity"; -import RegistrationHandler from "../../../../../../../src/server/lib/routes/secondfactor/u2f/identity/RegistrationHandler"; -import AuthenticationSession = require("../../../../../../../src/server/lib/AuthenticationSession"); +import { Identity } from "../../../../../types/Identity"; +import RegistrationHandler from "../../../../../src/lib/routes/secondfactor/u2f/identity/RegistrationHandler"; +import AuthenticationSession = require("../../../../../src/lib/AuthenticationSession"); import ExpressMock = require("../../../../mocks/express"); import { UserDataStoreStub } from "../../../../mocks/storage/UserDataStoreStub"; diff --git a/test/unit/server/routes/secondfactor/u2f/register/post.test.ts b/server/test/routes/secondfactor/u2f/register/post.test.ts similarity index 94% rename from test/unit/server/routes/secondfactor/u2f/register/post.test.ts rename to server/test/routes/secondfactor/u2f/register/post.test.ts index 664fcea93..9a8ced388 100644 --- a/test/unit/server/routes/secondfactor/u2f/register/post.test.ts +++ b/server/test/routes/secondfactor/u2f/register/post.test.ts @@ -2,9 +2,9 @@ import sinon = require("sinon"); import BluebirdPromise = require("bluebird"); import assert = require("assert"); -import U2FRegisterPost = require("../../../../../../../src/server/lib/routes/secondfactor/u2f/register/post"); -import AuthenticationSession = require("../../../../../../../src/server/lib/AuthenticationSession"); -import { ServerVariablesHandler } from "../../../../../../../src/server/lib/ServerVariablesHandler"; +import U2FRegisterPost = require("../../../../../src/lib/routes/secondfactor/u2f/register/post"); +import AuthenticationSession = require("../../../../../src/lib/AuthenticationSession"); +import { ServerVariablesHandler } from "../../../../../src/lib/ServerVariablesHandler"; import winston = require("winston"); import ExpressMock = require("../../../../mocks/express"); diff --git a/test/unit/server/routes/secondfactor/u2f/register_request/get.test.ts b/server/test/routes/secondfactor/u2f/register_request/get.test.ts similarity index 90% rename from test/unit/server/routes/secondfactor/u2f/register_request/get.test.ts rename to server/test/routes/secondfactor/u2f/register_request/get.test.ts index e647f9442..0a6fae7ae 100644 --- a/test/unit/server/routes/secondfactor/u2f/register_request/get.test.ts +++ b/server/test/routes/secondfactor/u2f/register_request/get.test.ts @@ -2,9 +2,9 @@ import sinon = require("sinon"); import BluebirdPromise = require("bluebird"); import assert = require("assert"); -import U2FRegisterRequestGet = require("../../../../../../../src/server/lib/routes/secondfactor/u2f/register_request/get"); -import AuthenticationSession = require("../../../../../../../src/server/lib/AuthenticationSession"); -import { ServerVariablesHandler } from "../../../../../../../src/server/lib/ServerVariablesHandler"; +import U2FRegisterRequestGet = require("../../../../../src/lib/routes/secondfactor/u2f/register_request/get"); +import AuthenticationSession = require("../../../../../src/lib/AuthenticationSession"); +import { ServerVariablesHandler } from "../../../../../src/lib/ServerVariablesHandler"; import winston = require("winston"); import ExpressMock = require("../../../../mocks/express"); diff --git a/test/unit/server/routes/secondfactor/u2f/sign/post.test.ts b/server/test/routes/secondfactor/u2f/sign/post.test.ts similarity index 90% rename from test/unit/server/routes/secondfactor/u2f/sign/post.test.ts rename to server/test/routes/secondfactor/u2f/sign/post.test.ts index c033a287b..54784f0c6 100644 --- a/test/unit/server/routes/secondfactor/u2f/sign/post.test.ts +++ b/server/test/routes/secondfactor/u2f/sign/post.test.ts @@ -2,9 +2,9 @@ import sinon = require("sinon"); import BluebirdPromise = require("bluebird"); import Assert = require("assert"); -import U2FSignPost = require("../../../../../../../src/server/lib/routes/secondfactor/u2f/sign/post"); -import AuthenticationSession = require("../../../../../../../src/server/lib/AuthenticationSession"); -import { ServerVariablesHandler } from "../../../../../../../src/server/lib/ServerVariablesHandler"; +import U2FSignPost = require("../../../../../src/lib/routes/secondfactor/u2f/sign/post"); +import AuthenticationSession = require("../../../../../src/lib/AuthenticationSession"); +import { ServerVariablesHandler } from "../../../../../src/lib/ServerVariablesHandler"; import winston = require("winston"); import ExpressMock = require("../../../../mocks/express"); diff --git a/test/unit/server/routes/secondfactor/u2f/sign_request/get.test.ts b/server/test/routes/secondfactor/u2f/sign_request/get.test.ts similarity index 84% rename from test/unit/server/routes/secondfactor/u2f/sign_request/get.test.ts rename to server/test/routes/secondfactor/u2f/sign_request/get.test.ts index 82fd79cb8..9e3027b43 100644 --- a/test/unit/server/routes/secondfactor/u2f/sign_request/get.test.ts +++ b/server/test/routes/secondfactor/u2f/sign_request/get.test.ts @@ -2,9 +2,9 @@ import sinon = require("sinon"); import BluebirdPromise = require("bluebird"); import assert = require("assert"); -import U2FSignRequestGet = require("../../../../../../../src/server/lib/routes/secondfactor/u2f/sign_request/get"); -import AuthenticationSession = require("../../../../../../../src/server/lib/AuthenticationSession"); -import { ServerVariablesHandler } from "../../../../../../../src/server/lib/ServerVariablesHandler"; +import U2FSignRequestGet = require("../../../../../src/lib/routes/secondfactor/u2f/sign_request/get"); +import AuthenticationSession = require("../../../../../src/lib/AuthenticationSession"); +import { ServerVariablesHandler } from "../../../../../src/lib/ServerVariablesHandler"; import winston = require("winston"); import ExpressMock = require("../../../../mocks/express"); @@ -13,7 +13,7 @@ import ServerVariablesMock = require("../../../../mocks/ServerVariablesMock"); import U2FMock = require("../../../../mocks/u2f"); import U2f = require("u2f"); -import { SignMessage } from "../../../../../../../src/server/lib/routes/secondfactor/u2f/sign_request/SignMessage"; +import { SignMessage } from "../../../../../../shared/SignMessage"; describe("test u2f routes: sign_request", function () { let req: ExpressMock.RequestMock; diff --git a/test/unit/server/routes/verify/get.test.ts b/server/test/routes/verify/get.test.ts similarity index 97% rename from test/unit/server/routes/verify/get.test.ts rename to server/test/routes/verify/get.test.ts index deee7d54a..1f257c22e 100644 --- a/test/unit/server/routes/verify/get.test.ts +++ b/server/test/routes/verify/get.test.ts @@ -1,7 +1,7 @@ import Assert = require("assert"); -import VerifyGet = require("../../../../../src/server/lib/routes/verify/get"); -import AuthenticationSession = require("../../../../../src/server/lib/AuthenticationSession"); +import VerifyGet = require("../../../src/lib/routes/verify/get"); +import AuthenticationSession = require("../../../src/lib/AuthenticationSession"); import Sinon = require("sinon"); import winston = require("winston"); diff --git a/test/unit/server/server/PrivatePages.ts b/server/test/server/PrivatePages.ts similarity index 94% rename from test/unit/server/server/PrivatePages.ts rename to server/test/server/PrivatePages.ts index 520b9f596..44a8411cf 100644 --- a/test/unit/server/server/PrivatePages.ts +++ b/server/test/server/PrivatePages.ts @@ -1,14 +1,14 @@ -import Server from "../../../../src/server/lib/Server"; +import Server from "../../src/lib/Server"; import BluebirdPromise = require("bluebird"); import speakeasy = require("speakeasy"); import request = require("request"); import nedb = require("nedb"); -import { GlobalDependencies } from "../../../../src/types/Dependencies"; -import { UserConfiguration } from "../../../../src/server/lib/configuration/Configuration"; -import { TOTPSecret } from "../../../../src/types/TOTPSecret"; +import { GlobalDependencies } from "../../types/Dependencies"; +import { UserConfiguration } from "../../src/lib/configuration/Configuration"; +import { TOTPSecret } from "../../types/TOTPSecret"; import U2FMock = require("./../mocks/u2f"); -import Endpoints = require("../../../../src/server/endpoints"); +import Endpoints = require("../../../shared/api"); import Requests = require("../requests"); import Assert = require("assert"); import Sinon = require("sinon"); diff --git a/test/unit/server/server/PublicPages.ts b/server/test/server/PublicPages.ts similarity index 92% rename from test/unit/server/server/PublicPages.ts rename to server/test/server/PublicPages.ts index 44ede36a6..180642fe9 100644 --- a/test/unit/server/server/PublicPages.ts +++ b/server/test/server/PublicPages.ts @@ -1,14 +1,14 @@ -import Server from "../../../../src/server/lib/Server"; +import Server from "../../src/lib/Server"; import BluebirdPromise = require("bluebird"); import speakeasy = require("speakeasy"); import Request = require("request"); import nedb = require("nedb"); -import { GlobalDependencies } from "../../../../src/types/Dependencies"; -import { UserConfiguration } from "../../../../src/server/lib/configuration/Configuration"; -import { TOTPSecret } from "../../../../src/types/TOTPSecret"; +import { GlobalDependencies } from "../../types/Dependencies"; +import { UserConfiguration } from "../../src/lib/configuration/Configuration"; +import { TOTPSecret } from "../../types/TOTPSecret"; import U2FMock = require("./../mocks/u2f"); -import Endpoints = require("../../../../src/server/endpoints"); +import Endpoints = require("../../../shared/api"); import Requests = require("../requests"); import Assert = require("assert"); import Sinon = require("sinon"); diff --git a/test/unit/server/storage/UserDataStore.test.ts b/server/test/storage/UserDataStore.test.ts similarity index 96% rename from test/unit/server/storage/UserDataStore.test.ts rename to server/test/storage/UserDataStore.test.ts index 44b1eaada..fcf2abbb5 100644 --- a/test/unit/server/storage/UserDataStore.test.ts +++ b/server/test/storage/UserDataStore.test.ts @@ -4,10 +4,10 @@ import * as Sinon from "sinon"; import * as MockDate from "mockdate"; import BluebirdPromise = require("bluebird"); -import { UserDataStore } from "../../../../src/server/lib/storage/UserDataStore"; -import { TOTPSecret } from "../../../../src/types/TOTPSecret"; -import { U2FRegistration } from "../../../../src/types/U2FRegistration"; -import { AuthenticationTraceDocument } from "../../../../src/server/lib/storage/AuthenticationTraceDocument"; +import { UserDataStore } from "../../src/lib/storage/UserDataStore"; +import { TOTPSecret } from "../../types/TOTPSecret"; +import { U2FRegistration } from "../../types/U2FRegistration"; +import { AuthenticationTraceDocument } from "../../src/lib/storage/AuthenticationTraceDocument"; import { CollectionStub } from "../mocks/storage/CollectionStub"; import { CollectionFactoryStub } from "../mocks/storage/CollectionFactoryStub"; diff --git a/test/unit/server/storage/mongo/MongoCollection.test.ts b/server/test/storage/mongo/MongoCollection.test.ts similarity index 97% rename from test/unit/server/storage/mongo/MongoCollection.test.ts rename to server/test/storage/mongo/MongoCollection.test.ts index ab07a1df6..5edd46704 100644 --- a/test/unit/server/storage/mongo/MongoCollection.test.ts +++ b/server/test/storage/mongo/MongoCollection.test.ts @@ -3,7 +3,7 @@ import Sinon = require("sinon"); import MongoDB = require("mongodb"); import BluebirdPromise = require("bluebird"); import { MongoClientStub } from "../../mocks/connectors/mongo/MongoClientStub"; -import { MongoCollection } from "../../../../../src/server/lib/storage/mongo/MongoCollection"; +import { MongoCollection } from "../../../src/lib/storage/mongo/MongoCollection"; describe("MongoCollection", function () { let mongoCollectionStub: MongoDB.Collection; diff --git a/test/unit/server/storage/mongo/MongoCollectionFactory.test.ts b/server/test/storage/mongo/MongoCollectionFactory.test.ts similarity index 83% rename from test/unit/server/storage/mongo/MongoCollectionFactory.test.ts rename to server/test/storage/mongo/MongoCollectionFactory.test.ts index c414c92e9..eab3da9a6 100644 --- a/test/unit/server/storage/mongo/MongoCollectionFactory.test.ts +++ b/server/test/storage/mongo/MongoCollectionFactory.test.ts @@ -1,7 +1,7 @@ import Assert = require("assert"); import Sinon = require("sinon"); import { MongoClientStub } from "../../mocks/connectors/mongo/MongoClientStub"; -import { MongoCollectionFactory } from "../../../../../src/server/lib/storage/mongo/MongoCollectionFactory"; +import { MongoCollectionFactory } from "../../../src/lib/storage/mongo/MongoCollectionFactory"; describe("MongoCollectionFactory", function () { let mongoClient: MongoClientStub; diff --git a/test/unit/server/storage/nedb/NedbCollection.test.ts b/server/test/storage/nedb/NedbCollection.test.ts similarity index 97% rename from test/unit/server/storage/nedb/NedbCollection.test.ts rename to server/test/storage/nedb/NedbCollection.test.ts index 9d6a9a6f2..16c79b4ef 100644 --- a/test/unit/server/storage/nedb/NedbCollection.test.ts +++ b/server/test/storage/nedb/NedbCollection.test.ts @@ -1,7 +1,7 @@ import Sinon = require("sinon"); import Assert = require("assert"); -import { NedbCollection } from "../../../../../src/server/lib/storage/nedb/NedbCollection"; +import { NedbCollection } from "../../../src/lib/storage/nedb/NedbCollection"; describe("NedbCollection", function () { describe("insert", function () { diff --git a/test/unit/server/storage/nedb/NedbCollectionFactory.test.ts b/server/test/storage/nedb/NedbCollectionFactory.test.ts similarity index 77% rename from test/unit/server/storage/nedb/NedbCollectionFactory.test.ts rename to server/test/storage/nedb/NedbCollectionFactory.test.ts index 4994a8f8d..d63390914 100644 --- a/test/unit/server/storage/nedb/NedbCollectionFactory.test.ts +++ b/server/test/storage/nedb/NedbCollectionFactory.test.ts @@ -1,7 +1,7 @@ import Sinon = require("sinon"); import Assert = require("assert"); -import { NedbCollectionFactory } from "../../../../../src/server/lib/storage/nedb/NedbCollectionFactory"; +import { NedbCollectionFactory } from "../../../src/lib/storage/nedb/NedbCollectionFactory"; describe("NedbCollectionFactory", function() { it("should create a nedb collection", function() { diff --git a/server/tsconfig.json b/server/tsconfig.json new file mode 100644 index 000000000..0bb4d62ff --- /dev/null +++ b/server/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "moduleResolution": "node", + "noImplicitAny": true, + "sourceMap": true, + "removeComments": true, + "outDir": "../dist", + "baseUrl": ".", + "paths": { + "*": [ + "./types/*", + "../shared/types/*" + ] + } + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "test/**/*" + ] +} diff --git a/server/tslint.json b/server/tslint.json new file mode 100644 index 000000000..c2c1b7501 --- /dev/null +++ b/server/tslint.json @@ -0,0 +1,60 @@ +{ + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "no-var-keyword": true, + "quotemark": [ + true, + "double", + "avoid-escape" + ], + "semicolon": [ + true, + "always", + "ignore-bound-class-methods" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-module", + "check-separator", + "check-type" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ], + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-null-keyword": true, + "prefer-const": true, + "jsdoc-format": true + } +} diff --git a/src/types/Dependencies.ts b/server/types/Dependencies.ts similarity index 100% rename from src/types/Dependencies.ts rename to server/types/Dependencies.ts diff --git a/src/types/Identity.ts b/server/types/Identity.ts similarity index 100% rename from src/types/Identity.ts rename to server/types/Identity.ts diff --git a/src/types/TOTPSecret.ts b/server/types/TOTPSecret.ts similarity index 100% rename from src/types/TOTPSecret.ts rename to server/types/TOTPSecret.ts diff --git a/src/types/U2FRegistration.ts b/server/types/U2FRegistration.ts similarity index 100% rename from src/types/U2FRegistration.ts rename to server/types/U2FRegistration.ts diff --git a/src/types/dovehash.d.ts b/server/types/dovehash.d.ts similarity index 100% rename from src/types/dovehash.d.ts rename to server/types/dovehash.d.ts diff --git a/src/server/lib/routes/secondfactor/u2f/sign_request/SignMessage.ts b/shared/SignMessage.ts similarity index 98% rename from src/server/lib/routes/secondfactor/u2f/sign_request/SignMessage.ts rename to shared/SignMessage.ts index c2f495c2a..8031ed632 100644 --- a/src/server/lib/routes/secondfactor/u2f/sign_request/SignMessage.ts +++ b/shared/SignMessage.ts @@ -1,4 +1,3 @@ - import U2f = require("u2f"); export interface SignMessage { diff --git a/src/server/endpoints.ts b/shared/api.ts similarity index 100% rename from src/server/endpoints.ts rename to shared/api.ts diff --git a/src/server/constants.ts b/shared/constants.ts similarity index 100% rename from src/server/constants.ts rename to shared/constants.ts diff --git a/src/types/u2f.d.ts b/shared/types/u2f.d.ts similarity index 100% rename from src/types/u2f.d.ts rename to shared/types/u2f.d.ts diff --git a/src/types/ldapjs-async.d.ts b/src/types/ldapjs-async.d.ts deleted file mode 100644 index 9fce7f516..000000000 --- a/src/types/ldapjs-async.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import ldapjs = require("ldapjs"); -import * as BluebirdPromise from "bluebird"; -import { EventEmitter } from "events"; - -declare module "ldapjs" { - export interface ClientAsync { - on(event: string, callback: (data?: any) => void): void; - bindAsync(username: string, password: string): BluebirdPromise; - unbindAsync(): BluebirdPromise; - searchAsync(base: string, query: ldapjs.SearchOptions): BluebirdPromise; - modifyAsync(userdn: string, change: ldapjs.Change): BluebirdPromise; - } -} \ No newline at end of file diff --git a/src/types/nedb-async.d.ts b/src/types/nedb-async.d.ts deleted file mode 100644 index 3f5c96b8e..000000000 --- a/src/types/nedb-async.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Nedb = require("nedb"); -import BluebirdPromise = require("bluebird"); - -declare module "nedb" { - export class NedbAsync extends Nedb { - constructor(pathOrOptions?: string | Nedb.DataStoreOptions); - updateAsync(query: any, updateQuery: any, options?: Nedb.UpdateOptions): BluebirdPromise; - findOneAsync(query: any): BluebirdPromise; - insertAsync(newDoc: T): BluebirdPromise; - removeAsync(query: any): BluebirdPromise; - countAsync(query: any): BluebirdPromise - } -} \ No newline at end of file diff --git a/src/types/request-async.d.ts b/src/types/request-async.d.ts deleted file mode 100644 index 964a7b24e..000000000 --- a/src/types/request-async.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as BluebirdPromise from "bluebird"; - -declare module "request" { - export interface RequestAPI { - getAsync(uri: string, options?: RequiredUriUrl): BluebirdPromise; - getAsync(uri: string): BluebirdPromise; - getAsync(options: RequiredUriUrl & CoreOptions): BluebirdPromise; - - postAsync(uri: string, options?: CoreOptions): BluebirdPromise; - postAsync(uri: string): BluebirdPromise; - postAsync(options: RequiredUriUrl & CoreOptions): BluebirdPromise; - } -} \ No newline at end of file diff --git a/test/features/access-control.feature b/test/features/access-control.feature index 4a3a8554f..e540ac576 100644 --- a/test/features/access-control.feature +++ b/test/features/access-control.feature @@ -2,10 +2,11 @@ Feature: User has access restricted access to domains @need-registered-user-john Scenario: User john has admin access - When I visit "https://auth.test.local:8080" + When I visit "https://auth.test.local:8080?redirect=https%3A%2F%2Fhome.test.local%3A8080%2F" And I login with user "john" and password "password" And I use "REGISTERED" as TOTP token handle And I click on "TOTP" + And I'm redirected to "https://home.test.local:8080/" Then I have access to: | url | | https://public.test.local:8080/secret.html | @@ -23,10 +24,11 @@ Feature: User has access restricted access to domains @need-registered-user-bob Scenario: User bob has restricted access - When I visit "https://auth.test.local:8080" + When I visit "https://auth.test.local:8080?redirect=https%3A%2F%2Fhome.test.local%3A8080%2F" And I login with user "bob" and password "password" And I use "REGISTERED" as TOTP token handle And I click on "TOTP" + And I'm redirected to "https://home.test.local:8080/" Then I have access to: | url | | https://public.test.local:8080/secret.html | @@ -44,10 +46,11 @@ Feature: User has access restricted access to domains @need-registered-user-harry Scenario: User harry has restricted access - When I visit "https://auth.test.local:8080" + When I visit "https://auth.test.local:8080?redirect=https%3A%2F%2Fhome.test.local%3A8080%2F" And I login with user "harry" and password "password" And I use "REGISTERED" as TOTP token handle And I click on "TOTP" + And I'm redirected to "https://home.test.local:8080/" Then I have access to: | url | | https://public.test.local:8080/secret.html | diff --git a/test/features/step_definitions/authentication.ts b/test/features/step_definitions/authentication.ts index ac3f398c4..140434e8e 100644 --- a/test/features/step_definitions/authentication.ts +++ b/test/features/step_definitions/authentication.ts @@ -4,6 +4,7 @@ import Assert = require("assert"); import Fs = require("fs"); import Speakeasy = require("speakeasy"); import CustomWorld = require("../support/world"); +import BluebirdPromise = require("bluebird"); Cucumber.defineSupportCode(function ({ Given, When, Then }) { When(/^I visit "(https:\/\/[a-zA-Z0-9:%&._\/=?-]+)"$/, function (link: string) { @@ -83,7 +84,7 @@ and I use TOTP token handle {stringInDoubleQuotes}", const url = (dataTable.hashes() as any)[i].url; promises.push(hasAccessToSecret(url, this)); } - return Promise.all(promises); + return BluebirdPromise.all(promises); }); Then("I have no access to:", function (dataTable: Cucumber.TableDefinition) { @@ -92,6 +93,6 @@ and I use TOTP token handle {stringInDoubleQuotes}", const url = (dataTable.hashes() as any)[i].url; promises.push(hasNoAccessToSecret(url, this)); } - return Promise.all(promises); + return BluebirdPromise.all(promises); }); }); \ No newline at end of file diff --git a/test/features/step_definitions/hooks.ts b/test/features/step_definitions/hooks.ts index 184a66d21..b8dcddfcd 100644 --- a/test/features/step_definitions/hooks.ts +++ b/test/features/step_definitions/hooks.ts @@ -2,11 +2,11 @@ import Cucumber = require("cucumber"); import fs = require("fs"); import BluebirdPromise = require("bluebird"); import ChildProcess = require("child_process"); -import { UserDataStore } from "../../../src/server/lib/storage/UserDataStore"; -import { CollectionFactoryFactory } from "../../../src/server/lib/storage/CollectionFactoryFactory"; -import { MongoConnector } from "../../../src/server/lib/connectors/mongo/MongoConnector"; -import { IMongoClient } from "../../../src/server/lib/connectors/mongo/IMongoClient"; -import { TOTPGenerator } from "../../../src/server/lib/TOTPGenerator"; +import { UserDataStore } from "../../../server/src/lib/storage/UserDataStore"; +import { CollectionFactoryFactory } from "../../../server/src/lib/storage/CollectionFactoryFactory"; +import { MongoConnector } from "../../../server/src/lib/connectors/mongo/MongoConnector"; +import { IMongoClient } from "../../../server/src/lib/connectors/mongo/IMongoClient"; +import { TOTPGenerator } from "../../../server/src/lib/TOTPGenerator"; import Speakeasy = require("speakeasy"); Cucumber.defineSupportCode(function ({ setDefaultTimeout }) {