disable assigning account for user if there is no my_email, my_name, my_uuid
[why]: my_email, my_name, my_uuid is required when initialize the default config file
[how]: check if the data has keys: my_email, my_name, my_uuid when get apply account request. the apply account will return with 'no my info' if missing any of my_email, my_name or my_uuid.
Signed-off-by: Luan Shengde luanshengde2@huawei.com --- container/assign-account/assign-account.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/container/assign-account/assign-account.rb b/container/assign-account/assign-account.rb index e356c18..3afcc9f 100755 --- a/container/assign-account/assign-account.rb +++ b/container/assign-account/assign-account.rb @@ -7,7 +7,7 @@ require 'sinatra' require 'open3' require 'json' require 'yaml' -require_relative 'get_account_info.rb' +require_relative 'get_account_info'
set :bind, '0.0.0.0' set :port, 29999 @@ -17,8 +17,12 @@ get '/assign_account' do data = YAML.safe_load request.body.read rescue StandardError => e puts e.message + puts e.backtrace end
+ message = 'lack of my infos(my_email, my_name, my_uuid)' + raise message unless %w[my_email my_name my_uuid].to_set.subset? data.keys.to_set + ref_account_info = AccountStorage.new(data) account_info = ref_account_info.setup_jumper_account_info