diff --git a/src/oc_erchef/apps/chef_license/src/chef_license_worker.erl b/src/oc_erchef/apps/chef_license/src/chef_license_worker.erl index bb63dc7fef..488b9d3b9c 100644 --- a/src/oc_erchef/apps/chef_license/src/chef_license_worker.erl +++ b/src/oc_erchef/apps/chef_license/src/chef_license_worker.erl @@ -95,6 +95,8 @@ check_license(State) -> State#state{license_cache=commercial_grace_period, grace_period=true, scanned_time = erlang:timestamp(), expiration_date=ExpDate, message=Msg}; {ok, trial_expired, ExpDate, Msg} -> State#state{license_cache=trial_expired_expired, license_type = <<"trial">>, grace_period=undefined, scanned_time = erlang:timestamp(), expiration_date=ExpDate, message=Msg}; + {error, no_license} -> + State#state{license_cache=trial_expired_expired, license_type = <<"trial">>, grace_period=undefined, scanned_time = erlang:timestamp(), expiration_date="", message=get_alert_message(trial_expired, "")}; {error, _} -> State end. @@ -133,6 +135,13 @@ process_license(LicJson) -> _ -> {error, invalid_response} end; + undefined -> + case ej:get({<<"status">>}, LicJson) of + <<"OK">> -> + {error, no_license}; + _ -> + {error, invalid_response} + end; _ -> {error, invalid_response} end. @@ -140,9 +149,9 @@ process_license(LicJson) -> get_alert_message(Type, ExpDate)-> case Type of trial_expired -> - "Your Progress Chef InfraServer license has expired or does not exist! You no longer have access to Chef Automate. Please contact the Account Team to upgrade to an Enterprise License."; + "Your Progress Chef InfraServer license has expired or does not exist! You no longer have access to Chef InfraServer. Please contact the Account Team to upgrade to an Enterprise License."; commercial_expired -> - "Your Progress Chef InfraServer license expired on " ++ ExpDate ++ " and you no longer have access to Chef Automate! To get a new license, please contact the Account Team or email us at chef-account-team@progress.com"; + "Your Progress Chef InfraServer license expired on " ++ ExpDate ++ " and you no longer have access to Chef InfraServer! To get a new license, please contact the Account Team or email us at chef-account-team@progress.com"; commercial_grace_period -> "Your Progress Chef InfraServer license expired on " ++ ExpDate ++ " and you are currently on a limited extension period! To get a new license, please contact the Account Team or email us at chef-account-team@progress.com" end. diff --git a/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm.app.src b/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm.app.src index 1783409b4a..aeee8ec5ca 100644 --- a/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm.app.src +++ b/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm.app.src @@ -24,7 +24,8 @@ goldrush, lager, eldap, - data_collector + data_collector, + chef_license ]}, {mod, {oc_chef_wm_app, []}}, {env, []} diff --git a/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm_base.erl b/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm_base.erl index ba05d2bb93..fa91de4ee4 100644 --- a/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm_base.erl +++ b/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm_base.erl @@ -100,9 +100,9 @@ service_available(Req, #base_state{reqid_header_name = HeaderName} = State) -> XOps = binary_to_list(chef_json:encode({[{<<"licenseType">>, Type},{<<"expirationDateTime">>, list_to_binary(ExpDate)}, {<<"warningMessage">>, list_to_binary(LicWarnMsg)}]})), Req1 = wrq:set_resp_header("X-Ops-License", XOps, Req), - Req2 = chef_wm_util:set_json_body(Req1, {[{<<"error">>, <<"invalid-license">>}, - {<<"message">>, list_to_binary(LicWarnMsg)}]}), - {{halt, 402}, Req2, State#base_state{log_msg = invalid_license}}; + Req2 = chef_wm_util:set_json_body(Req1, {[{<<"error">>, list_to_binary(LicWarnMsg)}, + {<<"message">>, <<"invalid-license">>}]}), + {{halt, 403}, Req2, State#base_state{log_msg = invalid_license}}; _ -> {true, Req, State3} end