From 16c0666d784306cc56542e0939078677def1e3b7 Mon Sep 17 00:00:00 2001 From: Luis Mesas Date: Fri, 26 Feb 2016 18:06:55 -0800 Subject: [PATCH 1/6] moved tests folders --- package.json | 12 ++++++------ {features => tests-acceptance}/cors.feature | 0 .../forgot_passwd.feature | 0 {features => tests-acceptance}/google.feature | 0 {features => tests-acceptance}/linkedin.feature | 0 {features => tests-acceptance}/login.feature | 0 {features => tests-acceptance}/post_profile.feature | 0 {features => tests-acceptance}/proxy.feature | 0 .../restrictedArea.feature | 0 {features => tests-acceptance}/salesforce.feature | 0 .../client_application_with_valid_token.js | 0 .../step_definitions/client_pass_through.js | 0 .../step_definitions/client_pass_through_pin.js | 0 .../step_definitions/config_params.js | 0 .../google/google_callback_response.js | 0 .../google/request_login_with_google.js | 0 .../step_definitions/linkedin_callback_response.js | 0 .../step_definitions/login_invalid_request.js | 0 .../step_definitions/login_invalid_username.js | 0 .../step_definitions/login_valid_request.js | 0 .../step_definitions/method_request_to_path.js | 0 .../step_definitions/protected_service_call.js | 0 .../step_definitions/protected_service_definiton.js | 0 .../step_definitions/reques_login_with_linkedin.js | 0 .../response_body_contains_json_attribute.js | 0 .../step_definitions/response_body_content.js | 0 .../step_definitions/response_has_no_error.js | 0 .../step_definitions/response_header_content.js | 0 .../response_headers_contains_attribute.js | 0 .../step_definitions/response_status_code_value.js | 0 .../step_definitions/salesforce/login_process.js | 0 .../salesforce/salesforce_callback.js | 0 .../salesforce/user_linked_to_salesforce.js | 0 .../salesforce/user_not_linked_to_salesforce.js | 0 ...he_app_requests_a_magic_link_for_a_valid_user.js | 0 .../the_response_headers_contains_the_header_x.js | 0 .../the_user_clicks_the_received_magic_link.js | 0 .../the_user_receives_a_magic_link_email.js | 0 .../step_definitions/user_with_valid_credentials.js | 0 {features => tests-acceptance}/support/hooks.js | 0 {features => tests-acceptance}/support/service.js | 0 .../support/serviceValidCors.js | 0 {features => tests-acceptance}/support/world.js | 0 {tests => tests-unit}/auth.js | 0 {tests => tests-unit}/auth/facebook_token.js | 0 {tests => tests-unit}/auth/google.js | 0 {tests => tests-unit}/auth/in.js | 0 {tests => tests-unit}/auth/login.js | 0 {tests => tests-unit}/auth/logout.js | 0 {tests => tests-unit}/auth/renew.js | 0 {tests => tests-unit}/auth/sf.js | 0 {tests => tests-unit}/auth/user.js | 0 {tests => tests-unit}/crypto.js | 0 {tests => tests-unit}/dao.js | 0 {tests => tests-unit}/email.js | 0 {tests => tests-unit}/emailAvailable.js | 0 {tests => tests-unit}/fileStore.js | 0 {tests => tests-unit}/fixtures/User.json | 0 {tests => tests-unit}/heartbeat.js | 0 {tests => tests-unit}/jsonValidator.js | 0 {tests => tests-unit}/managerToken.js | 0 {tests => tests-unit}/managerUser.js | 0 {tests => tests-unit}/managers/crypto.js | 0 {tests => tests-unit}/managers/email.js | 0 .../middlewares/authHeaderRequired.js | 0 {tests => tests-unit}/middlewares/decodeToken.js | 0 {tests => tests-unit}/phone.js | 0 {tests => tests-unit}/pinValidation.js | 0 {tests => tests-unit}/platforms/salesforce.js | 0 {tests => tests-unit}/prepareOptions.js | 0 {tests => tests-unit}/proxy.js | 0 .../proxy/protectedCallsPassThrough.js | 0 .../proxy/protectedCallsStandard-platformSF.js | 0 .../proxy/protectedCallsStandard.js | 0 .../public_routes/auth/loginEmail_post.js | 0 .../public_routes/auth/loginRefreshToken.js | 0 .../public_routes/user/forgotPassword_get.js | 0 {tests => tests-unit}/redirect.js | 0 {tests => tests-unit}/redis.js | 0 .../resources/sfProfileTemplate.js | 0 {tests => tests-unit}/routesRealms.js | 0 {tests => tests-unit}/routesUser.js | 0 {tests => tests-unit}/server.js | 0 {tests => tests-unit}/test_files/1234.jpg | Bin {tests => tests-unit}/test_files/empty proj.zip | Bin {tests => tests-unit}/test_files/empty.jpg | 0 {tests => tests-unit}/test_files/empty.png | 0 {tests => tests-unit}/userAppVersion.js | 0 {tests => tests-unit}/verifyPhone.js | 0 89 files changed, 6 insertions(+), 6 deletions(-) rename {features => tests-acceptance}/cors.feature (100%) rename {features => tests-acceptance}/forgot_passwd.feature (100%) rename {features => tests-acceptance}/google.feature (100%) rename {features => tests-acceptance}/linkedin.feature (100%) rename {features => tests-acceptance}/login.feature (100%) rename {features => tests-acceptance}/post_profile.feature (100%) rename {features => tests-acceptance}/proxy.feature (100%) rename {features => tests-acceptance}/restrictedArea.feature (100%) rename {features => tests-acceptance}/salesforce.feature (100%) rename {features => tests-acceptance}/step_definitions/client_application_with_valid_token.js (100%) rename {features => tests-acceptance}/step_definitions/client_pass_through.js (100%) rename {features => tests-acceptance}/step_definitions/client_pass_through_pin.js (100%) rename {features => tests-acceptance}/step_definitions/config_params.js (100%) rename {features => tests-acceptance}/step_definitions/google/google_callback_response.js (100%) rename {features => tests-acceptance}/step_definitions/google/request_login_with_google.js (100%) rename {features => tests-acceptance}/step_definitions/linkedin_callback_response.js (100%) rename {features => tests-acceptance}/step_definitions/login_invalid_request.js (100%) rename {features => tests-acceptance}/step_definitions/login_invalid_username.js (100%) rename {features => tests-acceptance}/step_definitions/login_valid_request.js (100%) rename {features => tests-acceptance}/step_definitions/method_request_to_path.js (100%) rename {features => tests-acceptance}/step_definitions/protected_service_call.js (100%) rename {features => tests-acceptance}/step_definitions/protected_service_definiton.js (100%) rename {features => tests-acceptance}/step_definitions/reques_login_with_linkedin.js (100%) rename {features => tests-acceptance}/step_definitions/response_body_contains_json_attribute.js (100%) rename {features => tests-acceptance}/step_definitions/response_body_content.js (100%) rename {features => tests-acceptance}/step_definitions/response_has_no_error.js (100%) rename {features => tests-acceptance}/step_definitions/response_header_content.js (100%) rename {features => tests-acceptance}/step_definitions/response_headers_contains_attribute.js (100%) rename {features => tests-acceptance}/step_definitions/response_status_code_value.js (100%) rename {features => tests-acceptance}/step_definitions/salesforce/login_process.js (100%) rename {features => tests-acceptance}/step_definitions/salesforce/salesforce_callback.js (100%) rename {features => tests-acceptance}/step_definitions/salesforce/user_linked_to_salesforce.js (100%) rename {features => tests-acceptance}/step_definitions/salesforce/user_not_linked_to_salesforce.js (100%) rename {features => tests-acceptance}/step_definitions/the_app_requests_a_magic_link_for_a_valid_user.js (100%) rename {features => tests-acceptance}/step_definitions/the_response_headers_contains_the_header_x.js (100%) rename {features => tests-acceptance}/step_definitions/the_user_clicks_the_received_magic_link.js (100%) rename {features => tests-acceptance}/step_definitions/the_user_receives_a_magic_link_email.js (100%) rename {features => tests-acceptance}/step_definitions/user_with_valid_credentials.js (100%) rename {features => tests-acceptance}/support/hooks.js (100%) rename {features => tests-acceptance}/support/service.js (100%) rename {features => tests-acceptance}/support/serviceValidCors.js (100%) rename {features => tests-acceptance}/support/world.js (100%) rename {tests => tests-unit}/auth.js (100%) rename {tests => tests-unit}/auth/facebook_token.js (100%) rename {tests => tests-unit}/auth/google.js (100%) rename {tests => tests-unit}/auth/in.js (100%) rename {tests => tests-unit}/auth/login.js (100%) rename {tests => tests-unit}/auth/logout.js (100%) rename {tests => tests-unit}/auth/renew.js (100%) rename {tests => tests-unit}/auth/sf.js (100%) rename {tests => tests-unit}/auth/user.js (100%) rename {tests => tests-unit}/crypto.js (100%) rename {tests => tests-unit}/dao.js (100%) rename {tests => tests-unit}/email.js (100%) rename {tests => tests-unit}/emailAvailable.js (100%) rename {tests => tests-unit}/fileStore.js (100%) rename {tests => tests-unit}/fixtures/User.json (100%) rename {tests => tests-unit}/heartbeat.js (100%) rename {tests => tests-unit}/jsonValidator.js (100%) rename {tests => tests-unit}/managerToken.js (100%) rename {tests => tests-unit}/managerUser.js (100%) rename {tests => tests-unit}/managers/crypto.js (100%) rename {tests => tests-unit}/managers/email.js (100%) rename {tests => tests-unit}/middlewares/authHeaderRequired.js (100%) rename {tests => tests-unit}/middlewares/decodeToken.js (100%) rename {tests => tests-unit}/phone.js (100%) rename {tests => tests-unit}/pinValidation.js (100%) rename {tests => tests-unit}/platforms/salesforce.js (100%) rename {tests => tests-unit}/prepareOptions.js (100%) rename {tests => tests-unit}/proxy.js (100%) rename {tests => tests-unit}/proxy/protectedCallsPassThrough.js (100%) rename {tests => tests-unit}/proxy/protectedCallsStandard-platformSF.js (100%) rename {tests => tests-unit}/proxy/protectedCallsStandard.js (100%) rename {tests => tests-unit}/public_routes/auth/loginEmail_post.js (100%) rename {tests => tests-unit}/public_routes/auth/loginRefreshToken.js (100%) rename {tests => tests-unit}/public_routes/user/forgotPassword_get.js (100%) rename {tests => tests-unit}/redirect.js (100%) rename {tests => tests-unit}/redis.js (100%) rename {tests => tests-unit}/resources/sfProfileTemplate.js (100%) rename {tests => tests-unit}/routesRealms.js (100%) rename {tests => tests-unit}/routesUser.js (100%) rename {tests => tests-unit}/server.js (100%) rename {tests => tests-unit}/test_files/1234.jpg (100%) rename {tests => tests-unit}/test_files/empty proj.zip (100%) rename {tests => tests-unit}/test_files/empty.jpg (100%) rename {tests => tests-unit}/test_files/empty.png (100%) rename {tests => tests-unit}/userAppVersion.js (100%) rename {tests => tests-unit}/verifyPhone.js (100%) diff --git a/package.json b/package.json index f0582ba..191e5d4 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "main": "src/cipherlayer.js", "scripts": { "test": "npm run-script jshint && npm run-script mocha && npm run-script features", - "mocha": "mocha tests --recursive", - "features": "./node_modules/cucumber/bin/cucumber.js features -f pretty --tags ~@ignore", - "features-only": "./node_modules/cucumber/bin/cucumber.js features -f pretty --tags @only", - "jshint": "node_modules/.bin/jshint ./src ./tests ./features main.js", - "coverage-unit": "istanbul cover --root src --include-all-sources --lcovonly --dir ./coverage/unit _mocha -- tests --recursive --reporter mocha-lcov-reporter", - "coverage-acceptance": "istanbul cover --root src --include-all-sources --lcovonly --dir ./coverage/acceptance cucumber.js -- --tags ~@ignore --format json", + "mocha": "mocha tests-unit --recursive", + "features": "cucumber.js tests-acceptance -f pretty --tags ~@ignore", + "features-only": "cucumber.js tests-acceptance -f pretty --tags @only", + "jshint": "jshint ./src ./tests-unit ./tests-acceptance main.js", + "coverage-unit": "istanbul cover --root src --include-all-sources --lcovonly --dir ./coverage/unit _mocha -- tests-unit --recursive --reporter mocha-lcov-reporter", + "coverage-acceptance": "istanbul cover --root src --include-all-sources --lcovonly --dir ./coverage/acceptance cucumber.js -- tests-acceptance --tags ~@ignore --format json", "coverage-merge": "istanbul-combine coverage/**/coverage.json", "coverage": "npm run coverage-unit && npm run coverage-acceptance && npm run coverage-merge", "coveralls": "istanbul-coveralls", diff --git a/features/cors.feature b/tests-acceptance/cors.feature similarity index 100% rename from features/cors.feature rename to tests-acceptance/cors.feature diff --git a/features/forgot_passwd.feature b/tests-acceptance/forgot_passwd.feature similarity index 100% rename from features/forgot_passwd.feature rename to tests-acceptance/forgot_passwd.feature diff --git a/features/google.feature b/tests-acceptance/google.feature similarity index 100% rename from features/google.feature rename to tests-acceptance/google.feature diff --git a/features/linkedin.feature b/tests-acceptance/linkedin.feature similarity index 100% rename from features/linkedin.feature rename to tests-acceptance/linkedin.feature diff --git a/features/login.feature b/tests-acceptance/login.feature similarity index 100% rename from features/login.feature rename to tests-acceptance/login.feature diff --git a/features/post_profile.feature b/tests-acceptance/post_profile.feature similarity index 100% rename from features/post_profile.feature rename to tests-acceptance/post_profile.feature diff --git a/features/proxy.feature b/tests-acceptance/proxy.feature similarity index 100% rename from features/proxy.feature rename to tests-acceptance/proxy.feature diff --git a/features/restrictedArea.feature b/tests-acceptance/restrictedArea.feature similarity index 100% rename from features/restrictedArea.feature rename to tests-acceptance/restrictedArea.feature diff --git a/features/salesforce.feature b/tests-acceptance/salesforce.feature similarity index 100% rename from features/salesforce.feature rename to tests-acceptance/salesforce.feature diff --git a/features/step_definitions/client_application_with_valid_token.js b/tests-acceptance/step_definitions/client_application_with_valid_token.js similarity index 100% rename from features/step_definitions/client_application_with_valid_token.js rename to tests-acceptance/step_definitions/client_application_with_valid_token.js diff --git a/features/step_definitions/client_pass_through.js b/tests-acceptance/step_definitions/client_pass_through.js similarity index 100% rename from features/step_definitions/client_pass_through.js rename to tests-acceptance/step_definitions/client_pass_through.js diff --git a/features/step_definitions/client_pass_through_pin.js b/tests-acceptance/step_definitions/client_pass_through_pin.js similarity index 100% rename from features/step_definitions/client_pass_through_pin.js rename to tests-acceptance/step_definitions/client_pass_through_pin.js diff --git a/features/step_definitions/config_params.js b/tests-acceptance/step_definitions/config_params.js similarity index 100% rename from features/step_definitions/config_params.js rename to tests-acceptance/step_definitions/config_params.js diff --git a/features/step_definitions/google/google_callback_response.js b/tests-acceptance/step_definitions/google/google_callback_response.js similarity index 100% rename from features/step_definitions/google/google_callback_response.js rename to tests-acceptance/step_definitions/google/google_callback_response.js diff --git a/features/step_definitions/google/request_login_with_google.js b/tests-acceptance/step_definitions/google/request_login_with_google.js similarity index 100% rename from features/step_definitions/google/request_login_with_google.js rename to tests-acceptance/step_definitions/google/request_login_with_google.js diff --git a/features/step_definitions/linkedin_callback_response.js b/tests-acceptance/step_definitions/linkedin_callback_response.js similarity index 100% rename from features/step_definitions/linkedin_callback_response.js rename to tests-acceptance/step_definitions/linkedin_callback_response.js diff --git a/features/step_definitions/login_invalid_request.js b/tests-acceptance/step_definitions/login_invalid_request.js similarity index 100% rename from features/step_definitions/login_invalid_request.js rename to tests-acceptance/step_definitions/login_invalid_request.js diff --git a/features/step_definitions/login_invalid_username.js b/tests-acceptance/step_definitions/login_invalid_username.js similarity index 100% rename from features/step_definitions/login_invalid_username.js rename to tests-acceptance/step_definitions/login_invalid_username.js diff --git a/features/step_definitions/login_valid_request.js b/tests-acceptance/step_definitions/login_valid_request.js similarity index 100% rename from features/step_definitions/login_valid_request.js rename to tests-acceptance/step_definitions/login_valid_request.js diff --git a/features/step_definitions/method_request_to_path.js b/tests-acceptance/step_definitions/method_request_to_path.js similarity index 100% rename from features/step_definitions/method_request_to_path.js rename to tests-acceptance/step_definitions/method_request_to_path.js diff --git a/features/step_definitions/protected_service_call.js b/tests-acceptance/step_definitions/protected_service_call.js similarity index 100% rename from features/step_definitions/protected_service_call.js rename to tests-acceptance/step_definitions/protected_service_call.js diff --git a/features/step_definitions/protected_service_definiton.js b/tests-acceptance/step_definitions/protected_service_definiton.js similarity index 100% rename from features/step_definitions/protected_service_definiton.js rename to tests-acceptance/step_definitions/protected_service_definiton.js diff --git a/features/step_definitions/reques_login_with_linkedin.js b/tests-acceptance/step_definitions/reques_login_with_linkedin.js similarity index 100% rename from features/step_definitions/reques_login_with_linkedin.js rename to tests-acceptance/step_definitions/reques_login_with_linkedin.js diff --git a/features/step_definitions/response_body_contains_json_attribute.js b/tests-acceptance/step_definitions/response_body_contains_json_attribute.js similarity index 100% rename from features/step_definitions/response_body_contains_json_attribute.js rename to tests-acceptance/step_definitions/response_body_contains_json_attribute.js diff --git a/features/step_definitions/response_body_content.js b/tests-acceptance/step_definitions/response_body_content.js similarity index 100% rename from features/step_definitions/response_body_content.js rename to tests-acceptance/step_definitions/response_body_content.js diff --git a/features/step_definitions/response_has_no_error.js b/tests-acceptance/step_definitions/response_has_no_error.js similarity index 100% rename from features/step_definitions/response_has_no_error.js rename to tests-acceptance/step_definitions/response_has_no_error.js diff --git a/features/step_definitions/response_header_content.js b/tests-acceptance/step_definitions/response_header_content.js similarity index 100% rename from features/step_definitions/response_header_content.js rename to tests-acceptance/step_definitions/response_header_content.js diff --git a/features/step_definitions/response_headers_contains_attribute.js b/tests-acceptance/step_definitions/response_headers_contains_attribute.js similarity index 100% rename from features/step_definitions/response_headers_contains_attribute.js rename to tests-acceptance/step_definitions/response_headers_contains_attribute.js diff --git a/features/step_definitions/response_status_code_value.js b/tests-acceptance/step_definitions/response_status_code_value.js similarity index 100% rename from features/step_definitions/response_status_code_value.js rename to tests-acceptance/step_definitions/response_status_code_value.js diff --git a/features/step_definitions/salesforce/login_process.js b/tests-acceptance/step_definitions/salesforce/login_process.js similarity index 100% rename from features/step_definitions/salesforce/login_process.js rename to tests-acceptance/step_definitions/salesforce/login_process.js diff --git a/features/step_definitions/salesforce/salesforce_callback.js b/tests-acceptance/step_definitions/salesforce/salesforce_callback.js similarity index 100% rename from features/step_definitions/salesforce/salesforce_callback.js rename to tests-acceptance/step_definitions/salesforce/salesforce_callback.js diff --git a/features/step_definitions/salesforce/user_linked_to_salesforce.js b/tests-acceptance/step_definitions/salesforce/user_linked_to_salesforce.js similarity index 100% rename from features/step_definitions/salesforce/user_linked_to_salesforce.js rename to tests-acceptance/step_definitions/salesforce/user_linked_to_salesforce.js diff --git a/features/step_definitions/salesforce/user_not_linked_to_salesforce.js b/tests-acceptance/step_definitions/salesforce/user_not_linked_to_salesforce.js similarity index 100% rename from features/step_definitions/salesforce/user_not_linked_to_salesforce.js rename to tests-acceptance/step_definitions/salesforce/user_not_linked_to_salesforce.js diff --git a/features/step_definitions/the_app_requests_a_magic_link_for_a_valid_user.js b/tests-acceptance/step_definitions/the_app_requests_a_magic_link_for_a_valid_user.js similarity index 100% rename from features/step_definitions/the_app_requests_a_magic_link_for_a_valid_user.js rename to tests-acceptance/step_definitions/the_app_requests_a_magic_link_for_a_valid_user.js diff --git a/features/step_definitions/the_response_headers_contains_the_header_x.js b/tests-acceptance/step_definitions/the_response_headers_contains_the_header_x.js similarity index 100% rename from features/step_definitions/the_response_headers_contains_the_header_x.js rename to tests-acceptance/step_definitions/the_response_headers_contains_the_header_x.js diff --git a/features/step_definitions/the_user_clicks_the_received_magic_link.js b/tests-acceptance/step_definitions/the_user_clicks_the_received_magic_link.js similarity index 100% rename from features/step_definitions/the_user_clicks_the_received_magic_link.js rename to tests-acceptance/step_definitions/the_user_clicks_the_received_magic_link.js diff --git a/features/step_definitions/the_user_receives_a_magic_link_email.js b/tests-acceptance/step_definitions/the_user_receives_a_magic_link_email.js similarity index 100% rename from features/step_definitions/the_user_receives_a_magic_link_email.js rename to tests-acceptance/step_definitions/the_user_receives_a_magic_link_email.js diff --git a/features/step_definitions/user_with_valid_credentials.js b/tests-acceptance/step_definitions/user_with_valid_credentials.js similarity index 100% rename from features/step_definitions/user_with_valid_credentials.js rename to tests-acceptance/step_definitions/user_with_valid_credentials.js diff --git a/features/support/hooks.js b/tests-acceptance/support/hooks.js similarity index 100% rename from features/support/hooks.js rename to tests-acceptance/support/hooks.js diff --git a/features/support/service.js b/tests-acceptance/support/service.js similarity index 100% rename from features/support/service.js rename to tests-acceptance/support/service.js diff --git a/features/support/serviceValidCors.js b/tests-acceptance/support/serviceValidCors.js similarity index 100% rename from features/support/serviceValidCors.js rename to tests-acceptance/support/serviceValidCors.js diff --git a/features/support/world.js b/tests-acceptance/support/world.js similarity index 100% rename from features/support/world.js rename to tests-acceptance/support/world.js diff --git a/tests/auth.js b/tests-unit/auth.js similarity index 100% rename from tests/auth.js rename to tests-unit/auth.js diff --git a/tests/auth/facebook_token.js b/tests-unit/auth/facebook_token.js similarity index 100% rename from tests/auth/facebook_token.js rename to tests-unit/auth/facebook_token.js diff --git a/tests/auth/google.js b/tests-unit/auth/google.js similarity index 100% rename from tests/auth/google.js rename to tests-unit/auth/google.js diff --git a/tests/auth/in.js b/tests-unit/auth/in.js similarity index 100% rename from tests/auth/in.js rename to tests-unit/auth/in.js diff --git a/tests/auth/login.js b/tests-unit/auth/login.js similarity index 100% rename from tests/auth/login.js rename to tests-unit/auth/login.js diff --git a/tests/auth/logout.js b/tests-unit/auth/logout.js similarity index 100% rename from tests/auth/logout.js rename to tests-unit/auth/logout.js diff --git a/tests/auth/renew.js b/tests-unit/auth/renew.js similarity index 100% rename from tests/auth/renew.js rename to tests-unit/auth/renew.js diff --git a/tests/auth/sf.js b/tests-unit/auth/sf.js similarity index 100% rename from tests/auth/sf.js rename to tests-unit/auth/sf.js diff --git a/tests/auth/user.js b/tests-unit/auth/user.js similarity index 100% rename from tests/auth/user.js rename to tests-unit/auth/user.js diff --git a/tests/crypto.js b/tests-unit/crypto.js similarity index 100% rename from tests/crypto.js rename to tests-unit/crypto.js diff --git a/tests/dao.js b/tests-unit/dao.js similarity index 100% rename from tests/dao.js rename to tests-unit/dao.js diff --git a/tests/email.js b/tests-unit/email.js similarity index 100% rename from tests/email.js rename to tests-unit/email.js diff --git a/tests/emailAvailable.js b/tests-unit/emailAvailable.js similarity index 100% rename from tests/emailAvailable.js rename to tests-unit/emailAvailable.js diff --git a/tests/fileStore.js b/tests-unit/fileStore.js similarity index 100% rename from tests/fileStore.js rename to tests-unit/fileStore.js diff --git a/tests/fixtures/User.json b/tests-unit/fixtures/User.json similarity index 100% rename from tests/fixtures/User.json rename to tests-unit/fixtures/User.json diff --git a/tests/heartbeat.js b/tests-unit/heartbeat.js similarity index 100% rename from tests/heartbeat.js rename to tests-unit/heartbeat.js diff --git a/tests/jsonValidator.js b/tests-unit/jsonValidator.js similarity index 100% rename from tests/jsonValidator.js rename to tests-unit/jsonValidator.js diff --git a/tests/managerToken.js b/tests-unit/managerToken.js similarity index 100% rename from tests/managerToken.js rename to tests-unit/managerToken.js diff --git a/tests/managerUser.js b/tests-unit/managerUser.js similarity index 100% rename from tests/managerUser.js rename to tests-unit/managerUser.js diff --git a/tests/managers/crypto.js b/tests-unit/managers/crypto.js similarity index 100% rename from tests/managers/crypto.js rename to tests-unit/managers/crypto.js diff --git a/tests/managers/email.js b/tests-unit/managers/email.js similarity index 100% rename from tests/managers/email.js rename to tests-unit/managers/email.js diff --git a/tests/middlewares/authHeaderRequired.js b/tests-unit/middlewares/authHeaderRequired.js similarity index 100% rename from tests/middlewares/authHeaderRequired.js rename to tests-unit/middlewares/authHeaderRequired.js diff --git a/tests/middlewares/decodeToken.js b/tests-unit/middlewares/decodeToken.js similarity index 100% rename from tests/middlewares/decodeToken.js rename to tests-unit/middlewares/decodeToken.js diff --git a/tests/phone.js b/tests-unit/phone.js similarity index 100% rename from tests/phone.js rename to tests-unit/phone.js diff --git a/tests/pinValidation.js b/tests-unit/pinValidation.js similarity index 100% rename from tests/pinValidation.js rename to tests-unit/pinValidation.js diff --git a/tests/platforms/salesforce.js b/tests-unit/platforms/salesforce.js similarity index 100% rename from tests/platforms/salesforce.js rename to tests-unit/platforms/salesforce.js diff --git a/tests/prepareOptions.js b/tests-unit/prepareOptions.js similarity index 100% rename from tests/prepareOptions.js rename to tests-unit/prepareOptions.js diff --git a/tests/proxy.js b/tests-unit/proxy.js similarity index 100% rename from tests/proxy.js rename to tests-unit/proxy.js diff --git a/tests/proxy/protectedCallsPassThrough.js b/tests-unit/proxy/protectedCallsPassThrough.js similarity index 100% rename from tests/proxy/protectedCallsPassThrough.js rename to tests-unit/proxy/protectedCallsPassThrough.js diff --git a/tests/proxy/protectedCallsStandard-platformSF.js b/tests-unit/proxy/protectedCallsStandard-platformSF.js similarity index 100% rename from tests/proxy/protectedCallsStandard-platformSF.js rename to tests-unit/proxy/protectedCallsStandard-platformSF.js diff --git a/tests/proxy/protectedCallsStandard.js b/tests-unit/proxy/protectedCallsStandard.js similarity index 100% rename from tests/proxy/protectedCallsStandard.js rename to tests-unit/proxy/protectedCallsStandard.js diff --git a/tests/public_routes/auth/loginEmail_post.js b/tests-unit/public_routes/auth/loginEmail_post.js similarity index 100% rename from tests/public_routes/auth/loginEmail_post.js rename to tests-unit/public_routes/auth/loginEmail_post.js diff --git a/tests/public_routes/auth/loginRefreshToken.js b/tests-unit/public_routes/auth/loginRefreshToken.js similarity index 100% rename from tests/public_routes/auth/loginRefreshToken.js rename to tests-unit/public_routes/auth/loginRefreshToken.js diff --git a/tests/public_routes/user/forgotPassword_get.js b/tests-unit/public_routes/user/forgotPassword_get.js similarity index 100% rename from tests/public_routes/user/forgotPassword_get.js rename to tests-unit/public_routes/user/forgotPassword_get.js diff --git a/tests/redirect.js b/tests-unit/redirect.js similarity index 100% rename from tests/redirect.js rename to tests-unit/redirect.js diff --git a/tests/redis.js b/tests-unit/redis.js similarity index 100% rename from tests/redis.js rename to tests-unit/redis.js diff --git a/tests/resources/sfProfileTemplate.js b/tests-unit/resources/sfProfileTemplate.js similarity index 100% rename from tests/resources/sfProfileTemplate.js rename to tests-unit/resources/sfProfileTemplate.js diff --git a/tests/routesRealms.js b/tests-unit/routesRealms.js similarity index 100% rename from tests/routesRealms.js rename to tests-unit/routesRealms.js diff --git a/tests/routesUser.js b/tests-unit/routesUser.js similarity index 100% rename from tests/routesUser.js rename to tests-unit/routesUser.js diff --git a/tests/server.js b/tests-unit/server.js similarity index 100% rename from tests/server.js rename to tests-unit/server.js diff --git a/tests/test_files/1234.jpg b/tests-unit/test_files/1234.jpg similarity index 100% rename from tests/test_files/1234.jpg rename to tests-unit/test_files/1234.jpg diff --git a/tests/test_files/empty proj.zip b/tests-unit/test_files/empty proj.zip similarity index 100% rename from tests/test_files/empty proj.zip rename to tests-unit/test_files/empty proj.zip diff --git a/tests/test_files/empty.jpg b/tests-unit/test_files/empty.jpg similarity index 100% rename from tests/test_files/empty.jpg rename to tests-unit/test_files/empty.jpg diff --git a/tests/test_files/empty.png b/tests-unit/test_files/empty.png similarity index 100% rename from tests/test_files/empty.png rename to tests-unit/test_files/empty.png diff --git a/tests/userAppVersion.js b/tests-unit/userAppVersion.js similarity index 100% rename from tests/userAppVersion.js rename to tests-unit/userAppVersion.js diff --git a/tests/verifyPhone.js b/tests-unit/verifyPhone.js similarity index 100% rename from tests/verifyPhone.js rename to tests-unit/verifyPhone.js From 44df02f433cacfdcd8cdf32d3b5195b0600d5d47 Mon Sep 17 00:00:00 2001 From: Luis Mesas Date: Fri, 26 Feb 2016 18:15:21 -0800 Subject: [PATCH 2/6] removed todo logger --- src/logger/todo.js | 23 ----------------------- src/managers/phone.js | 2 -- src/middlewares/accessTokenParam.js | 4 +--- 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 src/logger/todo.js diff --git a/src/logger/todo.js b/src/logger/todo.js deleted file mode 100644 index 9895824..0000000 --- a/src/logger/todo.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var bunyan = require('bunyan'); -var fs = require('fs'); - -module.exports = function () { - - var dir = process.cwd() + '/logs'; - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); - } - - var log = bunyan.createLogger({ - name: 'cipherlayer-todo', - streams: [{ - type: 'rotating-file', - path: process.cwd() + '/logs/cipherlayer-todo.log', - period: '1d', - count: 30 - }] - }); - return log; -}(); diff --git a/src/managers/phone.js b/src/managers/phone.js index 05e06c2..117a1d6 100644 --- a/src/managers/phone.js +++ b/src/managers/phone.js @@ -2,7 +2,6 @@ var request = require('request'); var _ = require('lodash'); var countries = require('countries-info'); var redisMng = require('./redis'); -var todo = require('../logger/todo.js'); var _settings = {}; @@ -50,7 +49,6 @@ function sendPIN(phone, pin, cbk) { }; request(options, function (err) { - todo.warn('pin sms notification request must verify response code'); if (err) { return cbk(err); } diff --git a/src/middlewares/accessTokenParam.js b/src/middlewares/accessTokenParam.js index b636f38..e36de9b 100644 --- a/src/middlewares/accessTokenParam.js +++ b/src/middlewares/accessTokenParam.js @@ -1,12 +1,10 @@ -var todo = require('../logger/todo.js'); var config = require(process.cwd() + '/config.json'); function checkAccessTokenParam(req, res, next) { var paramAT = req.params.at; if (paramAT) { - todo.warn('config.authHeaderKey must not contain a space'); - req.headers.authorization = config.authHeaderKey + paramAT; + req.headers.authorization = config.authHeaderKey.trim() + ' ' + paramAT; } next(); From 6d4263b86566c7c1ed61678f94845ae85fea0706 Mon Sep 17 00:00:00 2001 From: Luis Mesas Date: Fri, 26 Feb 2016 18:56:34 -0800 Subject: [PATCH 3/6] split cipherlayer service into internal/public services files --- src/cipherlayer.js | 313 +++++++--------------------------------- src/internal_service.js | 77 ++++++++++ src/public_service.js | 132 +++++++++++++++++ 3 files changed, 262 insertions(+), 260 deletions(-) create mode 100644 src/internal_service.js create mode 100644 src/public_service.js diff --git a/src/cipherlayer.js b/src/cipherlayer.js index 5d00628..45c7be8 100644 --- a/src/cipherlayer.js +++ b/src/cipherlayer.js @@ -1,269 +1,62 @@ -var log = require('./logger/service.js'); -var restify = require('restify'); +'use strict'; + var async = require('async'); -var fs = require('fs'); -var path = require('path'); -var config = require(process.cwd() + '/config.json'); -var passport = require('passport'); -var _ = require('lodash'); var userDao = require('./managers/dao'); var redisMng = require('./managers/redis'); -var checkAccessTokenParam = require('./middlewares/accessTokenParam'); -var checkAuthHeader = require('./middlewares/authHeaderRequired'); -var decodeToken = require('./middlewares/decodeToken'); -var findUser = require('./middlewares/findUser'); -var prepareOptions = require('./middlewares/prepareOptions'); -var platformsSetUp = require('./middlewares/platformsSetUp'); -var propagateRequest = require('./middlewares/propagateRequest'); -var permissions = require('./middlewares/permissions'); -var bodyParserWrapper = require('./middlewares/bodyParserWrapper'); - -var versionControl = require('version-control'); - -var pinValidation = require('./middlewares/pinValidation')(); -var userAppVersion = require('./middlewares/userAppVersion')(); - -var publicServer; -var internalServer; - -function startDaos(cbk) { - userDao.connect(function () { - cbk(); - }); -} - -function stopDaos(cbk) { - userDao.disconnect(function () { - cbk(); - }); -} - -function startRedis(cbk) { - redisMng.connect(function () { - cbk(); - }); -} - -function stopRedis(cbk) { - redisMng.disconnect(function () { - cbk(); - }); -} - -function startListener(publicPort, internalPort, cbk) { - async.series([ - function (done) { - publicServer = restify.createServer({ - name: 'cipherlayer-server', - log: log - }); - - log.info('PUBLIC SERVICE starting on PORT ' + publicPort); - - publicServer.on('after', function (req, res) { - var logInfo = { - request: { - method: req.method, - headers: req.headers, - url: req.url, - path: req._url.pathname, - query: req._url.query, - params: req.params, - time: req._time - }, - response: { - statusCode: res.statusCode, - hasBody: res.hasBody, - bodySize: _.size(res.body), - time: Date.now() - }, - user: req.user, - tokenInfo: req.tokenInfo - }; - delete(logInfo.request.params.password); - - req.log.info(logInfo, "response"); - }); - - if (config.accessControlAllow) { - publicServer.use(restify.CORS({ - origins: config.accessControlAllow.origins, - credentials: true, - headers: config.accessControlAllow.headers - })); - - publicServer.opts(/.*/, function (req, res, next) { - res.header("Access-Control-Allow-Methods", req.header("Access-Control-Request-Methods")); - res.header("Access-Control-Allow-Headers", req.header("Access-Control-Request-Headers")); - res.send(200); - return next(); - }); +var publicService = require('./public_service'); +var privateService = require('./internal_service'); + +module.exports = function () { + var cipherlayer = {}; + + cipherlayer.start = function (publicPort, internalPort, cbk) { + //Validate the current config.json with the schema + //if( !jsonValidator.isValidJSON(config, configSchema)) { + // return cbk({err:'invalid_config_json', des:'The config.json is not updated, check for the last version.'}); + //} + + async.series([ + userDao.connect, + redisMng.connect, + function (done) { + publicService.start(publicPort, done); + }, + function (done) { + privateService.start(internalPort, done); } - - publicServer.use(restify.queryParser()); - publicServer.use(bodyParserWrapper(restify.bodyParser({maxBodySize: 1024 * 1024 * 3}))); - - var versionControlOptions = _.clone(config.version); - versionControlOptions.public = [ - "/auth/sf", - "/auth/sf/*", - "/auth/in", - "/auth/in/*", - "/auth/google", - "/auth/google/*", - "/auth/login/refreshToken*", - "/user/activate*", - "/heartbeat", - "/user/email/available" - ]; - publicServer.use(versionControl(versionControlOptions)); - - publicServer.on('uncaughtException', function (req, res, route, error) { - log.error({exception: {req: req, res: res, route: route, err: error}}); - if (!res.statusCode) { - res.send(500, {err: 'internal_error', des: 'uncaught exception'}); - } - }); - - var routesPath = path.join(__dirname, './public_routes/'); - fs.readdirSync(routesPath).forEach(function (filename) { - require(routesPath + filename)(publicServer); - }); - - var platformsPath = path.join(__dirname, '/platforms/'); - fs.readdirSync(platformsPath).forEach(function (filename) { - require(platformsPath + filename).addRoutes(publicServer, passport); - }); - - publicServer.get(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); - publicServer.post(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); - publicServer.del(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); - publicServer.put(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); - - publicServer.listen(publicPort, function () { - log.info('PUBLIC SERVICE listening on PORT ' + publicPort); - done(); - }); - }, - function (done) { - if (!internalPort) { - log.info('INTERNAL SERVICE not started because there is no internal_port in config'); - return done(); + ], function (err) { + cbk(err); + }); + }; + + cipherlayer.stop = function stop(cbk) { + async.series([ + userDao.disconnect, + redisMng.disconnect, + publicService.stop, + privateService.stop + ], function (err) { + cbk(err); + }); + }; + + cipherlayer.getStatus = function (cbk) { + async.series([ + function (done) { + userDao.getStatus(done); + }, + function (done) { + redisMng.getStatus(done); } - - log.info('INTERNAL SERVICE starting on PORT ' + internalPort); - - internalServer = restify.createServer({ - name: 'cipherlayer-internal-server', - log: log - }); - - internalServer.on('after', function (req, res) { - var logInfo = { - request: { - method: req.method, - headers: req.headers, - url: req.url, - path: req._url.pathname, - query: req._url.query, - params: req.params, - time: req._time - }, - response: { - statusCode: res.statusCode, - hasBody: res.hasBody, - bodySize: _.size(res.body), - time: Date.now() - }, - user: req.user, - tokenInfo: req.tokenInfo - }; - delete(logInfo.request.params.password); - - req.log.info(logInfo, "response"); - }); - - internalServer.use(restify.queryParser()); - internalServer.use(bodyParserWrapper(restify.bodyParser({maxBodySize: 1024 * 1024 * 3}))); - - var routesPath = path.join(__dirname, './internal_routes/'); - fs.readdirSync(routesPath).forEach(function (filename) { - require(routesPath + filename)(internalServer); - }); - - internalServer.listen(internalPort, function () { - log.info('INTERNAL SERVICE listening on PORT ' + internalPort); - done(); - }); - } - ], cbk); -} - -function stopListener(cbk) { - async.parallel([ - function (done) { - publicServer.close(function () { - done(); - }); - }, - function (done) { - if (!internalServer) { - return done(); + ], function (err) { + if (err) { + return cbk(err); } - internalServer.close(function () { - done(); - }); - } - ], cbk); -} - -function start(publicPort, internalPort, cbk) { - //Validate the current config.json with the schema - //if( !jsonValidator.isValidJSON(config, configSchema)) { - // return cbk({err:'invalid_config_json', des:'The config.json is not updated, check for the last version.'}); - //} - - async.series([ - startDaos, - startRedis, - function (done) { - startListener(publicPort, internalPort, done); - } - ], function (err) { - cbk(err); - }); -} - -function stop(cbk) { - async.series([ - stopDaos, - stopRedis, - stopListener - ], function (err) { - cbk(err); - }); -} - -function getStatus(cbk) { - async.series([ - function (done) { - userDao.getStatus(done); - }, - function (done) { - redisMng.getStatus(done); - } - ], function (err) { - if (err) { - return cbk(err); - } - cbk(); - }); -} + cbk(); + }); + }; -module.exports = { - start: start, - stop: stop, - getStatus: getStatus -}; + return cipherlayer; +}(); diff --git a/src/internal_service.js b/src/internal_service.js new file mode 100644 index 0000000..a0223b9 --- /dev/null +++ b/src/internal_service.js @@ -0,0 +1,77 @@ +'use strict'; + +var restify = require('restify'); +var fs = require('fs'); +var path = require('path'); +var _ = require('lodash'); + +var log = require('./logger/service.js'); +var bodyParserWrapper = require('./middlewares/bodyParserWrapper'); + +module.exports = function () { + var service = {}; + + var server; + service.start = function (internalPort, done) { + if (!internalPort) { + log.info('INTERNAL SERVICE not started because there is no internal_port in config'); + return done(); + } + + log.info('INTERNAL SERVICE starting on PORT ' + internalPort); + + server = restify.createServer({ + name: 'cipherlayer-internal-server', + log: log + }); + + server.on('after', function (req, res) { + var logInfo = { + request: { + method: req.method, + headers: req.headers, + url: req.url, + path: req._url.pathname, + query: req._url.query, + params: req.params, + time: req._time + }, + response: { + statusCode: res.statusCode, + hasBody: res.hasBody, + bodySize: _.size(res.body), + time: Date.now() + }, + user: req.user, + tokenInfo: req.tokenInfo + }; + delete(logInfo.request.params.password); + + req.log.info(logInfo, "response"); + }); + + server.use(restify.queryParser()); + server.use(bodyParserWrapper(restify.bodyParser({maxBodySize: 1024 * 1024 * 3}))); + + var routesPath = path.join(__dirname, './internal_routes/'); + fs.readdirSync(routesPath).forEach(function (filename) { + require(routesPath + filename)(server); + }); + + server.listen(internalPort, function () { + log.info('INTERNAL SERVICE listening on PORT ' + internalPort); + done(); + }); + }; + + service.stop = function (done) { + if (!server) { + return done(); + } + server.close(function () { + done(); + }); + }; + + return service; +}(); diff --git a/src/public_service.js b/src/public_service.js new file mode 100644 index 0000000..e07461b --- /dev/null +++ b/src/public_service.js @@ -0,0 +1,132 @@ +'use strict'; + +var log = require('./logger/service.js'); +var restify = require('restify'); +var fs = require('fs'); +var path = require('path'); +var config = require(process.cwd() + '/config.json'); +var passport = require('passport'); +var _ = require('lodash'); + +var checkAccessTokenParam = require('./middlewares/accessTokenParam'); +var checkAuthHeader = require('./middlewares/authHeaderRequired'); +var decodeToken = require('./middlewares/decodeToken'); +var findUser = require('./middlewares/findUser'); +var prepareOptions = require('./middlewares/prepareOptions'); +var platformsSetUp = require('./middlewares/platformsSetUp'); +var propagateRequest = require('./middlewares/propagateRequest'); +var permissions = require('./middlewares/permissions'); +var bodyParserWrapper = require('./middlewares/bodyParserWrapper'); + +var versionControl = require('version-control'); + +var pinValidation = require('./middlewares/pinValidation')(); +var userAppVersion = require('./middlewares/userAppVersion')(); + +module.exports = function () { + var service = {}; + + var server; + + service.start = function (publicPort, done) { + server = restify.createServer({ + name: 'cipherlayer-server', + log: log + }); + + log.info('PUBLIC SERVICE starting on PORT ' + publicPort); + + server.on('after', function (req, res) { + var logInfo = { + request: { + method: req.method, + headers: req.headers, + url: req.url, + path: req._url.pathname, + query: req._url.query, + params: req.params, + time: req._time + }, + response: { + statusCode: res.statusCode, + hasBody: res.hasBody, + bodySize: _.size(res.body), + time: Date.now() + }, + user: req.user, + tokenInfo: req.tokenInfo + }; + delete(logInfo.request.params.password); + + req.log.info(logInfo, "response"); + }); + + if (config.accessControlAllow) { + server.use(restify.CORS({ + origins: config.accessControlAllow.origins, + credentials: true, + headers: config.accessControlAllow.headers + })); + + server.opts(/.*/, function (req, res, next) { + res.header("Access-Control-Allow-Methods", req.header("Access-Control-Request-Methods")); + res.header("Access-Control-Allow-Headers", req.header("Access-Control-Request-Headers")); + res.send(200); + return next(); + }); + } + + server.use(restify.queryParser()); + server.use(bodyParserWrapper(restify.bodyParser({maxBodySize: 1024 * 1024 * 3}))); + + var versionControlOptions = _.clone(config.version); + versionControlOptions.public = [ + "/auth/sf", + "/auth/sf/*", + "/auth/in", + "/auth/in/*", + "/auth/google", + "/auth/google/*", + "/auth/login/refreshToken*", + "/user/activate*", + "/heartbeat", + "/user/email/available" + ]; + server.use(versionControl(versionControlOptions)); + + server.on('uncaughtException', function (req, res, route, error) { + log.error({exception: {req: req, res: res, route: route, err: error}}); + if (!res.statusCode) { + res.send(500, {err: 'internal_error', des: 'uncaught exception'}); + } + }); + + var routesPath = path.join(__dirname, './public_routes/'); + fs.readdirSync(routesPath).forEach(function (filename) { + require(routesPath + filename)(server); + }); + + var platformsPath = path.join(__dirname, '/platforms/'); + fs.readdirSync(platformsPath).forEach(function (filename) { + require(platformsPath + filename).addRoutes(server, passport); + }); + + server.get(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); + server.post(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); + server.del(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); + server.put(/(.*)/, checkAccessTokenParam, checkAuthHeader, decodeToken, permissions, findUser, pinValidation, userAppVersion, prepareOptions, platformsSetUp, propagateRequest); + + server.listen(publicPort, function () { + log.info('PUBLIC SERVICE listening on PORT ' + publicPort); + done(); + }); + }; + + service.stop = function (done) { + server.close(function () { + done(); + }); + }; + + return service; +}(); From b679fd93d119db3fa6a6622c7da2fd63caa27d45 Mon Sep 17 00:00:00 2001 From: Luis Mesas Date: Fri, 26 Feb 2016 19:35:41 -0800 Subject: [PATCH 4/6] routes refactor --- circle.yml | 2 +- .../auth/user_del.js | 0 .../auth/user_post.js | 0 .../{realms.js => realms/realms_get.js} | 14 ++-- src/internal_routes/routes.js | 13 ++++ src/internal_service.js | 9 +-- src/public_routes/auth.js | 25 ------- .../loginFacebook_post.js} | 22 +++--- src/public_routes/heartbeat.js | 18 ----- src/public_routes/heartbeat/heartbeat_get.js | 33 +++++++++ src/public_routes/routes.js | 47 +++++++++++++ src/public_routes/user.js | 70 ------------------- src/public_routes/user/setPassword_put.js | 22 ++++++ .../user/validateOldPassword_put.js | 28 ++++++++ src/public_service.js | 7 +- .../salesforce/user_linked_to_salesforce.js | 2 +- .../user_not_linked_to_salesforce.js | 2 +- .../user_with_valid_credentials.js | 2 +- tests-acceptance/support/service.js | 2 +- tests-acceptance/support/serviceValidCors.js | 2 +- tests-unit/auth/user.js | 12 ++-- 21 files changed, 175 insertions(+), 157 deletions(-) rename src/{public_routes => internal_routes}/auth/user_del.js (100%) rename src/{public_routes => internal_routes}/auth/user_post.js (100%) rename src/internal_routes/{realms.js => realms/realms_get.js} (55%) create mode 100644 src/internal_routes/routes.js delete mode 100644 src/public_routes/auth.js rename src/public_routes/{auth_facebook.js => auth/loginFacebook_post.js} (91%) delete mode 100644 src/public_routes/heartbeat.js create mode 100644 src/public_routes/heartbeat/heartbeat_get.js create mode 100644 src/public_routes/routes.js delete mode 100644 src/public_routes/user.js create mode 100644 src/public_routes/user/setPassword_put.js create mode 100644 src/public_routes/user/validateOldPassword_put.js diff --git a/circle.yml b/circle.yml index a51980f..2ec86f9 100644 --- a/circle.yml +++ b/circle.yml @@ -16,6 +16,6 @@ deployment: npm: branch: master commands: - - npm version 1.2.$CIRCLE_BUILD_NUM --no-git-tag-version + - npm version 1.3.$CIRCLE_BUILD_NUM --no-git-tag-version - echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login - npm publish diff --git a/src/public_routes/auth/user_del.js b/src/internal_routes/auth/user_del.js similarity index 100% rename from src/public_routes/auth/user_del.js rename to src/internal_routes/auth/user_del.js diff --git a/src/public_routes/auth/user_post.js b/src/internal_routes/auth/user_post.js similarity index 100% rename from src/public_routes/auth/user_post.js rename to src/internal_routes/auth/user_post.js diff --git a/src/internal_routes/realms.js b/src/internal_routes/realms/realms_get.js similarity index 55% rename from src/internal_routes/realms.js rename to src/internal_routes/realms/realms_get.js index 3e9c44d..b74825c 100644 --- a/src/internal_routes/realms.js +++ b/src/internal_routes/realms/realms_get.js @@ -1,6 +1,8 @@ -var daoMng = require('../managers/dao'); +'use strict'; -function getRealms(req, res, next) { +var daoMng = require('../../managers/dao'); + +module.exports = function getRealms(req, res, next) { daoMng.getRealms(function (err, realms) { if (err) { res.send(500, {err: 'internalError', des: 'Internal server error'}); @@ -12,10 +14,4 @@ function getRealms(req, res, next) { }); return next(); }); -} - -function addRoutes(service) { - service.get('/realms', getRealms); -} - -module.exports = addRoutes; +}; diff --git a/src/internal_routes/routes.js b/src/internal_routes/routes.js new file mode 100644 index 0000000..ddae622 --- /dev/null +++ b/src/internal_routes/routes.js @@ -0,0 +1,13 @@ +'use strict'; + +var checkAuthBasic = require('../middlewares/checkAuthBasic'); + +var realms_get = require('./realms/realms_get'); +var user_post = require('./auth/user_post'); +var user_del = require('./auth/user_del'); + +module.exports = function addRoutes(server) { + server.get('/realms', realms_get); + server.post('/auth/user', checkAuthBasic, user_post); + server.del('/auth/user', checkAuthBasic, user_del); +}; diff --git a/src/internal_service.js b/src/internal_service.js index a0223b9..61ca7b3 100644 --- a/src/internal_service.js +++ b/src/internal_service.js @@ -1,13 +1,13 @@ 'use strict'; var restify = require('restify'); -var fs = require('fs'); -var path = require('path'); var _ = require('lodash'); var log = require('./logger/service.js'); var bodyParserWrapper = require('./middlewares/bodyParserWrapper'); +var routes = require('./internal_routes/routes'); + module.exports = function () { var service = {}; @@ -53,10 +53,7 @@ module.exports = function () { server.use(restify.queryParser()); server.use(bodyParserWrapper(restify.bodyParser({maxBodySize: 1024 * 1024 * 3}))); - var routesPath = path.join(__dirname, './internal_routes/'); - fs.readdirSync(routesPath).forEach(function (filename) { - require(routesPath + filename)(server); - }); + routes(server); server.listen(internalPort, function () { log.info('INTERNAL SERVICE listening on PORT ' + internalPort); diff --git a/src/public_routes/auth.js b/src/public_routes/auth.js deleted file mode 100644 index 8f2204d..0000000 --- a/src/public_routes/auth.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -var checkAuthBasic = require('../middlewares/checkAuthBasic'); -var login_post = require('./auth/login_post'); -var user_post = require('./auth/user_post'); -var user_del = require('./auth/user_del'); -var renew_post = require('./auth/renew_post'); -var logout_post = require('./auth/logout_post'); -var loginEmail_post = require('./auth/loginEmail_post'); -var loginRefreshToken_get = require('./auth/loginRefreshToken_get'); - -var authHeaderRequired = require('../middlewares/authHeaderRequired'); -var decodeAccessToken = require('../middlewares/decodeToken'); - -module.exports = function addRoutes(service) { - service.post('/auth/login', login_post); - service.post('/auth/login/email', loginEmail_post); - service.get('/auth/login/refreshToken', loginRefreshToken_get); - - service.post('/auth/renew', renew_post); - service.post('/auth/logout', authHeaderRequired, decodeAccessToken, logout_post); - - service.post('/auth/user', checkAuthBasic, user_post); - service.del('/auth/user', checkAuthBasic, user_del); -}; diff --git a/src/public_routes/auth_facebook.js b/src/public_routes/auth/loginFacebook_post.js similarity index 91% rename from src/public_routes/auth_facebook.js rename to src/public_routes/auth/loginFacebook_post.js index 2beab52..43b83eb 100644 --- a/src/public_routes/auth_facebook.js +++ b/src/public_routes/auth/loginFacebook_post.js @@ -1,12 +1,14 @@ +'use strict'; + var request = require('request'); var _ = require('lodash'); -var log = require('../logger/service.js'); -var daoMng = require('../managers/dao'); -var userMng = require('../managers/user')(); -var tokenMng = require('../managers/token'); +var log = require('../../logger/service.js'); +var daoMng = require('../../managers/dao'); +var userMng = require('../../managers/user')(); +var tokenMng = require('../../managers/token'); var config = require(process.cwd() + '/config.json'); -var crypto = require('../managers/crypto'); +var crypto = require('../../managers/crypto'); var cryptoMng = crypto(config.password); var defaultOptions = { @@ -48,7 +50,7 @@ function mapFacebookData(body, fieldsMap) { return mappedData; } -function postAuthRegisterFacebook(req, res, next) { +module.exports = function postAuthRegisterFacebook(req, res, next) { var options = _.clone(defaultOptions); options.qs.access_token = req.body.accessToken; @@ -179,10 +181,4 @@ function postAuthRegisterFacebook(req, res, next) { }); }); -} - -function addRoutes(service) { - service.post('/auth/login/facebook', postAuthRegisterFacebook); -} - -module.exports = addRoutes; +}; diff --git a/src/public_routes/heartbeat.js b/src/public_routes/heartbeat.js deleted file mode 100644 index 73c2a6e..0000000 --- a/src/public_routes/heartbeat.js +++ /dev/null @@ -1,18 +0,0 @@ -var cipherlayer = require('../cipherlayer'); - -function getStatus(req, res, next) { - cipherlayer.getStatus(function (err) { - if (err) { - res.send(500, err); - return next(); - } - res.send(204); - return next(); - }); -} - -function addRoutes(service) { - service.get('/heartbeat', getStatus); -} - -module.exports = addRoutes; diff --git a/src/public_routes/heartbeat/heartbeat_get.js b/src/public_routes/heartbeat/heartbeat_get.js new file mode 100644 index 0000000..0bfd238 --- /dev/null +++ b/src/public_routes/heartbeat/heartbeat_get.js @@ -0,0 +1,33 @@ +'use strict'; + +var async = require('async'); + +var userDao = require('../../managers/dao'); +var redisMng = require('../../managers/redis'); + +function getStatus(cbk) { + async.series([ + function (done) { + userDao.getStatus(done); + }, + function (done) { + redisMng.getStatus(done); + } + ], function (err) { + if (err) { + return cbk(err); + } + cbk(); + }); +} + +module.exports = function (req, res, next) { + getStatus(function (err) { + if (err) { + res.send(500, err); + return next(); + } + res.send(204); + return next(); + }); +}; diff --git a/src/public_routes/routes.js b/src/public_routes/routes.js new file mode 100644 index 0000000..4569d42 --- /dev/null +++ b/src/public_routes/routes.js @@ -0,0 +1,47 @@ +'use strict'; + +var config = require(process.cwd() + '/config.json'); + +var authHeaderRequired = require('../middlewares/authHeaderRequired'); +var decodeAccessToken = require('../middlewares/decodeToken'); + +var login_post = require('./auth/login_post'); +var renew_post = require('./auth/renew_post'); +var logout_post = require('./auth/logout_post'); +var loginEmail_post = require('./auth/loginEmail_post'); +var loginRefreshToken_get = require('./auth/loginRefreshToken_get'); + +var heartbeat_get = require('./heartbeat/heartbeat_get'); + +var authloginFacebook_post = require('./auth/loginFacebook_post'); + +var checkAccessTokenParam = require('../middlewares/accessTokenParam'); +var checkAuthHeader = require('../middlewares/authHeaderRequired'); +var decodeToken = require('../middlewares/decodeToken'); +var findUser = require('../middlewares/findUser'); +var bodyRequired = require('../middlewares/bodyRequired'); + +var forgotPassword_get = require('./user/forgotPassword_get'); +var activateUser_get = require('./user/activateUser_get'); +var activateUser_post = require('./user/activateUser_get'); +var checkEmailAvailability_post = require('./user/checkEmailAvailability_post'); +var createUser_post = require('./user/createUser_post'); + +var validateOldPassword = require('./user/validateOldPassword_put'); +var setPassword = require('./user/setPassword_put'); + +module.exports = function(server){ + server.post('/auth/login', login_post); + server.post('/auth/login/email', loginEmail_post); + server.get('/auth/login/refreshToken', loginRefreshToken_get); + server.post('/auth/renew', renew_post); + server.post('/auth/logout', authHeaderRequired, decodeAccessToken, logout_post); + server.get('/heartbeat', heartbeat_get); + server.post('/auth/login/facebook', authloginFacebook_post); + server.get('/user/:email/password', forgotPassword_get); + server.post(config.passThroughEndpoint.path, createUser_post); + server.get('/user/activate', activateUser_get); + server.post('/user/activate', activateUser_post); + server.post('/user/email/available', checkEmailAvailability_post); + server.put('/user/me/password', checkAccessTokenParam, checkAuthHeader, decodeToken, bodyRequired, findUser, validateOldPassword, setPassword); +}; diff --git a/src/public_routes/user.js b/src/public_routes/user.js deleted file mode 100644 index 19b7d90..0000000 --- a/src/public_routes/user.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -var config = require(process.cwd() + '/config.json'); -var userMng = require('../managers/user'); - -var checkAccessTokenParam = require('../middlewares/accessTokenParam'); -var checkAuthHeader = require('../middlewares/authHeaderRequired'); -var decodeToken = require('../middlewares/decodeToken'); -var findUser = require('../middlewares/findUser'); -var bodyRequired = require('../middlewares/bodyRequired'); - -var forgotPassword_get = require('./user/forgotPassword_get'); -var activateUser_get = require('./user/activateUser_get'); -var activateUser_post = require('./user/activateUser_get'); -var checkEmailAvailability_post = require('./user/checkEmailAvailability_post'); -var createUser_post = require('./user/createUser_post'); - -function validateOldPassword(req, res, next) { - var err; - if (!config.password.validateOldPassword) { - return next(); - } - - if (!req.body.oldPassword) { - err = { - err: 'missing_password', - des: 'Missing old password validation' - }; - res.send(400, err); - return next(false); - } - - userMng().validateOldPassword(req.user.username, req.body.oldPassword, function (err) { - if (err) { - res.send(401, err); - return next(false); - } - return next(); - }); -} - -function setPassword(req, res, next) { - userMng().setPassword(req.user._id, req.body, function (err) { - if (err) { - if (!err.code) { - res.send(500, err); - return next(false); - } - - var errCode = err.code; - delete(err.code); - res.send(errCode, err); - return next(false); - } - - res.send(204); - return next(); - }); -} - -function addRoutes(service) { - service.get('/user/:email/password', forgotPassword_get); - service.post(config.passThroughEndpoint.path, createUser_post); - service.get('/user/activate', activateUser_get); - service.post('/user/activate', activateUser_post); - service.post('/user/email/available', checkEmailAvailability_post); - service.put('/user/me/password', checkAccessTokenParam, checkAuthHeader, decodeToken, bodyRequired, findUser, validateOldPassword, setPassword); -} - -module.exports = addRoutes; diff --git a/src/public_routes/user/setPassword_put.js b/src/public_routes/user/setPassword_put.js new file mode 100644 index 0000000..cf453ac --- /dev/null +++ b/src/public_routes/user/setPassword_put.js @@ -0,0 +1,22 @@ +'use strict'; + +var userMng = require('../../managers/user'); + +module.exports = function (req, res, next) { + userMng().setPassword(req.user._id, req.body, function (err) { + if (err) { + if (!err.code) { + res.send(500, err); + return next(false); + } + + var errCode = err.code; + delete(err.code); + res.send(errCode, err); + return next(false); + } + + res.send(204); + return next(); + }); +}; diff --git a/src/public_routes/user/validateOldPassword_put.js b/src/public_routes/user/validateOldPassword_put.js new file mode 100644 index 0000000..1aba948 --- /dev/null +++ b/src/public_routes/user/validateOldPassword_put.js @@ -0,0 +1,28 @@ +'use strict'; + +var config = require(process.cwd() + '/config.json'); +var userMng = require('../../managers/user'); + +module.exports = function validateOldPassword(req, res, next) { + var err; + if (!config.password.validateOldPassword) { + return next(); + } + + if (!req.body.oldPassword) { + err = { + err: 'missing_password', + des: 'Missing old password validation' + }; + res.send(400, err); + return next(false); + } + + userMng().validateOldPassword(req.user.username, req.body.oldPassword, function (err) { + if (err) { + res.send(401, err); + return next(false); + } + return next(); + }); +}; diff --git a/src/public_service.js b/src/public_service.js index e07461b..c489496 100644 --- a/src/public_service.js +++ b/src/public_service.js @@ -23,6 +23,8 @@ var versionControl = require('version-control'); var pinValidation = require('./middlewares/pinValidation')(); var userAppVersion = require('./middlewares/userAppVersion')(); +var routes = require('./public_routes/routes'); + module.exports = function () { var service = {}; @@ -101,10 +103,7 @@ module.exports = function () { } }); - var routesPath = path.join(__dirname, './public_routes/'); - fs.readdirSync(routesPath).forEach(function (filename) { - require(routesPath + filename)(server); - }); + routes(server); var platformsPath = path.join(__dirname, '/platforms/'); fs.readdirSync(platformsPath).forEach(function (filename) { diff --git a/tests-acceptance/step_definitions/salesforce/user_linked_to_salesforce.js b/tests-acceptance/step_definitions/salesforce/user_linked_to_salesforce.js index 98cd96a..f62ca4d 100644 --- a/tests-acceptance/step_definitions/salesforce/user_linked_to_salesforce.js +++ b/tests-acceptance/step_definitions/salesforce/user_linked_to_salesforce.js @@ -16,7 +16,7 @@ module.exports = function () { }]; var options = { - url: 'http://localhost:' + config.public_port + '/auth/user', + url: 'http://localhost:' + config.internal_port + '/auth/user', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Authorization': 'basic ' + new Buffer(config.management.clientId + ':' + config.management.clientSecret).toString('base64') diff --git a/tests-acceptance/step_definitions/salesforce/user_not_linked_to_salesforce.js b/tests-acceptance/step_definitions/salesforce/user_not_linked_to_salesforce.js index a8e2716..8041df5 100644 --- a/tests-acceptance/step_definitions/salesforce/user_not_linked_to_salesforce.js +++ b/tests-acceptance/step_definitions/salesforce/user_not_linked_to_salesforce.js @@ -10,7 +10,7 @@ module.exports = function () { world.getUser().password = 'valid_password'; var options = { - url: 'http://localhost:' + config.public_port + '/auth/user', + url: 'http://localhost:' + config.internal_port + '/auth/user', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Authorization': 'basic ' + new Buffer(config.management.clientId + ':' + config.management.clientSecret).toString('base64') diff --git a/tests-acceptance/step_definitions/user_with_valid_credentials.js b/tests-acceptance/step_definitions/user_with_valid_credentials.js index f032c1a..4eba9f9 100644 --- a/tests-acceptance/step_definitions/user_with_valid_credentials.js +++ b/tests-acceptance/step_definitions/user_with_valid_credentials.js @@ -9,7 +9,7 @@ module.exports = function () { world.getUser().password = 'valid_password'; var options = { - url: 'http://localhost:' + config.public_port + '/auth/user', + url: 'http://localhost:' + config.internal_port + '/auth/user', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Authorization': 'basic ' + new Buffer(config.management.clientId + ':' + config.management.clientSecret).toString('base64') diff --git a/tests-acceptance/support/service.js b/tests-acceptance/support/service.js index 920dc51..1073a33 100644 --- a/tests-acceptance/support/service.js +++ b/tests-acceptance/support/service.js @@ -12,7 +12,7 @@ module.exports = function () { cipherlayer.start(config.public_port, config.internal_port, function (err) { assert.equal(err, null); var options = { - url: 'http://localhost:' + config.public_port + '/auth/user', + url: 'http://localhost:' + config.internal_port + '/auth/user', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Authorization': 'basic ' + new Buffer(config.management.clientId + ':' + config.management.clientSecret).toString('base64') diff --git a/tests-acceptance/support/serviceValidCors.js b/tests-acceptance/support/serviceValidCors.js index ed0e5ec..be15118 100644 --- a/tests-acceptance/support/serviceValidCors.js +++ b/tests-acceptance/support/serviceValidCors.js @@ -17,7 +17,7 @@ module.exports = function () { cipherlayer.start(config.public_port, config.internal_port, function (err) { assert.equal(err, null); var options = { - url: 'http://localhost:' + config.public_port + '/auth/user', + url: 'http://localhost:' + config.internal_port + '/auth/user', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Authorization': 'basic ' + new Buffer(config.management.clientId + ':' + config.management.clientSecret).toString('base64') diff --git a/tests-unit/auth/user.js b/tests-unit/auth/user.js index 7805501..f60a011 100644 --- a/tests-unit/auth/user.js +++ b/tests-unit/auth/user.js @@ -26,7 +26,7 @@ module.exports = { it('POST 201 created', function (done) { var options = { - url: 'http://' + config.private_host + ':' + config.public_port + '/auth/user', + url: 'http://' + config.private_host + ':' + config.internal_port + '/auth/user', headers: HEADERS_WITH_AUTHORIZATION_BASIC, method: 'POST', body: JSON.stringify({username: username, password: password, phone: phone}) @@ -45,7 +45,7 @@ module.exports = { it('401 Not authorized when trying to POST to /auth/user without basic authorization', function (done) { var options = { - url: 'http://' + config.private_host + ':' + config.public_port + '/auth/user', + url: 'http://' + config.private_host + ':' + config.internal_port + '/auth/user', headers: HEADERS_WITHOUT_AUTHORIZATION_BASIC, method: 'POST', body: JSON.stringify({username: username, password: password}) @@ -65,7 +65,7 @@ module.exports = { assert.notEqual(createdUser, null); var options = { - url: 'http://' + config.private_host + ':' + config.public_port + '/auth/user', + url: 'http://' + config.private_host + ':' + config.internal_port + '/auth/user', headers: HEADERS_WITH_AUTHORIZATION_BASIC, method: 'POST', body: JSON.stringify({username: USER.username, password: USER.password}) @@ -88,7 +88,7 @@ module.exports = { assert.notEqual(createdUser, null); var options = { - url: 'http://' + config.private_host + ':' + config.public_port + '/auth/user', + url: 'http://' + config.private_host + ':' + config.internal_port + '/auth/user', headers: HEADERS_WITHOUT_AUTHORIZATION_BASIC, method: 'POST', body: JSON.stringify({username: USER.username, password: USER.password}) @@ -108,7 +108,7 @@ module.exports = { assert.notEqual(createdUser, null); var options = { - url: 'http://' + config.private_host + ':' + config.public_port + '/auth/user', + url: 'http://' + config.private_host + ':' + config.internal_port + '/auth/user', headers: HEADERS_WITH_AUTHORIZATION_BASIC, method: 'DELETE' }; @@ -133,7 +133,7 @@ module.exports = { assert.notEqual(createdUser, null); var options = { - url: 'http://' + config.private_host + ':' + config.public_port + '/auth/user', + url: 'http://' + config.private_host + ':' + config.internal_port + '/auth/user', headers: HEADERS_WITHOUT_AUTHORIZATION_BASIC, method: 'DELETE' }; From bb2801c29ffb63840f986c7a87556c4f57eadcb4 Mon Sep 17 00:00:00 2001 From: Luis Mesas Date: Fri, 26 Feb 2016 19:41:17 -0800 Subject: [PATCH 5/6] changed routes folders --- src/internal_service.js | 2 +- src/public_service.js | 2 +- src/{internal_routes => routes_internal}/auth/user_del.js | 0 src/{internal_routes => routes_internal}/auth/user_post.js | 0 .../realms/realms_get.js | 0 src/{internal_routes => routes_internal}/routes.js | 0 .../auth/loginEmail_post.js | 0 .../auth/loginFacebook_post.js | 0 .../auth/loginRefreshToken_get.js | 0 src/{public_routes => routes_public}/auth/login_post.js | 0 src/{public_routes => routes_public}/auth/logout_post.js | 0 src/{public_routes => routes_public}/auth/renew_post.js | 0 src/{public_routes => routes_public}/auth/session.js | 0 .../heartbeat/heartbeat_get.js | 0 src/{public_routes => routes_public}/routes.js | 0 .../user/activateUser_get.js | 0 .../user/checkEmailAvailability_post.js | 0 .../user/createUser_post.js | 0 .../user/forgotPassword_get.js | 0 .../user/setPassword_put.js | 0 .../user/validateOldPassword_put.js | 0 tests-unit/public_routes/auth/loginEmail_post.js | 4 ++-- tests-unit/public_routes/auth/loginRefreshToken.js | 6 +++--- tests-unit/public_routes/user/forgotPassword_get.js | 2 +- 24 files changed, 8 insertions(+), 8 deletions(-) rename src/{internal_routes => routes_internal}/auth/user_del.js (100%) rename src/{internal_routes => routes_internal}/auth/user_post.js (100%) rename src/{internal_routes => routes_internal}/realms/realms_get.js (100%) rename src/{internal_routes => routes_internal}/routes.js (100%) rename src/{public_routes => routes_public}/auth/loginEmail_post.js (100%) rename src/{public_routes => routes_public}/auth/loginFacebook_post.js (100%) rename src/{public_routes => routes_public}/auth/loginRefreshToken_get.js (100%) rename src/{public_routes => routes_public}/auth/login_post.js (100%) rename src/{public_routes => routes_public}/auth/logout_post.js (100%) rename src/{public_routes => routes_public}/auth/renew_post.js (100%) rename src/{public_routes => routes_public}/auth/session.js (100%) rename src/{public_routes => routes_public}/heartbeat/heartbeat_get.js (100%) rename src/{public_routes => routes_public}/routes.js (100%) rename src/{public_routes => routes_public}/user/activateUser_get.js (100%) rename src/{public_routes => routes_public}/user/checkEmailAvailability_post.js (100%) rename src/{public_routes => routes_public}/user/createUser_post.js (100%) rename src/{public_routes => routes_public}/user/forgotPassword_get.js (100%) rename src/{public_routes => routes_public}/user/setPassword_put.js (100%) rename src/{public_routes => routes_public}/user/validateOldPassword_put.js (100%) diff --git a/src/internal_service.js b/src/internal_service.js index 61ca7b3..a91f1b0 100644 --- a/src/internal_service.js +++ b/src/internal_service.js @@ -6,7 +6,7 @@ var _ = require('lodash'); var log = require('./logger/service.js'); var bodyParserWrapper = require('./middlewares/bodyParserWrapper'); -var routes = require('./internal_routes/routes'); +var routes = require('./routes_internal/routes'); module.exports = function () { var service = {}; diff --git a/src/public_service.js b/src/public_service.js index c489496..bf25c80 100644 --- a/src/public_service.js +++ b/src/public_service.js @@ -23,7 +23,7 @@ var versionControl = require('version-control'); var pinValidation = require('./middlewares/pinValidation')(); var userAppVersion = require('./middlewares/userAppVersion')(); -var routes = require('./public_routes/routes'); +var routes = require('./routes_public/routes'); module.exports = function () { var service = {}; diff --git a/src/internal_routes/auth/user_del.js b/src/routes_internal/auth/user_del.js similarity index 100% rename from src/internal_routes/auth/user_del.js rename to src/routes_internal/auth/user_del.js diff --git a/src/internal_routes/auth/user_post.js b/src/routes_internal/auth/user_post.js similarity index 100% rename from src/internal_routes/auth/user_post.js rename to src/routes_internal/auth/user_post.js diff --git a/src/internal_routes/realms/realms_get.js b/src/routes_internal/realms/realms_get.js similarity index 100% rename from src/internal_routes/realms/realms_get.js rename to src/routes_internal/realms/realms_get.js diff --git a/src/internal_routes/routes.js b/src/routes_internal/routes.js similarity index 100% rename from src/internal_routes/routes.js rename to src/routes_internal/routes.js diff --git a/src/public_routes/auth/loginEmail_post.js b/src/routes_public/auth/loginEmail_post.js similarity index 100% rename from src/public_routes/auth/loginEmail_post.js rename to src/routes_public/auth/loginEmail_post.js diff --git a/src/public_routes/auth/loginFacebook_post.js b/src/routes_public/auth/loginFacebook_post.js similarity index 100% rename from src/public_routes/auth/loginFacebook_post.js rename to src/routes_public/auth/loginFacebook_post.js diff --git a/src/public_routes/auth/loginRefreshToken_get.js b/src/routes_public/auth/loginRefreshToken_get.js similarity index 100% rename from src/public_routes/auth/loginRefreshToken_get.js rename to src/routes_public/auth/loginRefreshToken_get.js diff --git a/src/public_routes/auth/login_post.js b/src/routes_public/auth/login_post.js similarity index 100% rename from src/public_routes/auth/login_post.js rename to src/routes_public/auth/login_post.js diff --git a/src/public_routes/auth/logout_post.js b/src/routes_public/auth/logout_post.js similarity index 100% rename from src/public_routes/auth/logout_post.js rename to src/routes_public/auth/logout_post.js diff --git a/src/public_routes/auth/renew_post.js b/src/routes_public/auth/renew_post.js similarity index 100% rename from src/public_routes/auth/renew_post.js rename to src/routes_public/auth/renew_post.js diff --git a/src/public_routes/auth/session.js b/src/routes_public/auth/session.js similarity index 100% rename from src/public_routes/auth/session.js rename to src/routes_public/auth/session.js diff --git a/src/public_routes/heartbeat/heartbeat_get.js b/src/routes_public/heartbeat/heartbeat_get.js similarity index 100% rename from src/public_routes/heartbeat/heartbeat_get.js rename to src/routes_public/heartbeat/heartbeat_get.js diff --git a/src/public_routes/routes.js b/src/routes_public/routes.js similarity index 100% rename from src/public_routes/routes.js rename to src/routes_public/routes.js diff --git a/src/public_routes/user/activateUser_get.js b/src/routes_public/user/activateUser_get.js similarity index 100% rename from src/public_routes/user/activateUser_get.js rename to src/routes_public/user/activateUser_get.js diff --git a/src/public_routes/user/checkEmailAvailability_post.js b/src/routes_public/user/checkEmailAvailability_post.js similarity index 100% rename from src/public_routes/user/checkEmailAvailability_post.js rename to src/routes_public/user/checkEmailAvailability_post.js diff --git a/src/public_routes/user/createUser_post.js b/src/routes_public/user/createUser_post.js similarity index 100% rename from src/public_routes/user/createUser_post.js rename to src/routes_public/user/createUser_post.js diff --git a/src/public_routes/user/forgotPassword_get.js b/src/routes_public/user/forgotPassword_get.js similarity index 100% rename from src/public_routes/user/forgotPassword_get.js rename to src/routes_public/user/forgotPassword_get.js diff --git a/src/public_routes/user/setPassword_put.js b/src/routes_public/user/setPassword_put.js similarity index 100% rename from src/public_routes/user/setPassword_put.js rename to src/routes_public/user/setPassword_put.js diff --git a/src/public_routes/user/validateOldPassword_put.js b/src/routes_public/user/validateOldPassword_put.js similarity index 100% rename from src/public_routes/user/validateOldPassword_put.js rename to src/routes_public/user/validateOldPassword_put.js diff --git a/tests-unit/public_routes/auth/loginEmail_post.js b/tests-unit/public_routes/auth/loginEmail_post.js index 86a644a..64a1ef9 100644 --- a/tests-unit/public_routes/auth/loginEmail_post.js +++ b/tests-unit/public_routes/auth/loginEmail_post.js @@ -83,7 +83,7 @@ describe('public routes', function () { done(); }; - var loginEmail_post = require('../../../src/public_routes/auth/loginEmail_post.js'); + var loginEmail_post = require('../../../src/routes_public/auth/loginEmail_post.js'); loginEmail_post(req, res, next); }); @@ -120,7 +120,7 @@ describe('public routes', function () { }; var nextSpy = sinon.spy(next, 'next'); - var loginEmail_post = require('../../../src/public_routes/auth/loginEmail_post.js'); + var loginEmail_post = require('../../../src/routes_public/auth/loginEmail_post.js'); loginEmail_post(req, res, next.next); }); }); diff --git a/tests-unit/public_routes/auth/loginRefreshToken.js b/tests-unit/public_routes/auth/loginRefreshToken.js index 89a9d5b..78d0b7b 100644 --- a/tests-unit/public_routes/auth/loginRefreshToken.js +++ b/tests-unit/public_routes/auth/loginRefreshToken.js @@ -68,7 +68,7 @@ describe('public routes', function () { }; var nextSpy = sinon.spy(next, 'next'); - var loginRefreshToken_get = require('../../../src/public_routes/auth/loginRefreshToken_get.js'); + var loginRefreshToken_get = require('../../../src/routes_public/auth/loginRefreshToken_get.js'); loginRefreshToken_get(req, res, next.next); }); @@ -114,7 +114,7 @@ describe('public routes', function () { }; var nextSpy = sinon.spy(next, 'next'); - var loginRefreshToken_get = require('../../../src/public_routes/auth/loginRefreshToken_get.js'); + var loginRefreshToken_get = require('../../../src/routes_public/auth/loginRefreshToken_get.js'); loginRefreshToken_get(req, res, next.next); }); @@ -148,7 +148,7 @@ describe('public routes', function () { }; var nextSpy = sinon.spy(next, 'next'); - var loginRefreshToken_get = require('../../../src/public_routes/auth/loginRefreshToken_get.js'); + var loginRefreshToken_get = require('../../../src/routes_public/auth/loginRefreshToken_get.js'); loginRefreshToken_get(req, res, next.next); }); }); diff --git a/tests-unit/public_routes/user/forgotPassword_get.js b/tests-unit/public_routes/user/forgotPassword_get.js index 16c48ef..d582c41 100644 --- a/tests-unit/public_routes/user/forgotPassword_get.js +++ b/tests-unit/public_routes/user/forgotPassword_get.js @@ -105,7 +105,7 @@ describe('public routes', function () { done(); }; - var forgotPassword_get = require('../../../src/public_routes/user/forgotPassword_get'); + var forgotPassword_get = require('../../../src/routes_public/user/forgotPassword_get'); forgotPassword_get(req, res, next); }); From 01fe20a3079c183b46425b0c867581a9083e0a2c Mon Sep 17 00:00:00 2001 From: Luis Mesas Date: Fri, 26 Feb 2016 19:47:19 -0800 Subject: [PATCH 6/6] removed unsused --- src/cipherlayer.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/cipherlayer.js b/src/cipherlayer.js index 45c7be8..702457e 100644 --- a/src/cipherlayer.js +++ b/src/cipherlayer.js @@ -42,21 +42,5 @@ module.exports = function () { }); }; - cipherlayer.getStatus = function (cbk) { - async.series([ - function (done) { - userDao.getStatus(done); - }, - function (done) { - redisMng.getStatus(done); - } - ], function (err) { - if (err) { - return cbk(err); - } - cbk(); - }); - }; - return cipherlayer; }();