Commit b9d4b1a9 by lanrion

#get_access_token should raise error if app_secret or appid is invalid

parent f1b63a54
...@@ -57,6 +57,7 @@ module WeixinAuthorize ...@@ -57,6 +57,7 @@ module WeixinAuthorize
# authenticate access_token # authenticate access_token
def authenticate def authenticate
raise "APPID or APPSECRET is invalid" if !is_valid?
if is_weixin_redis_blank? if is_weixin_redis_blank?
set_access_token_for_client set_access_token_for_client
else else
......
...@@ -19,9 +19,14 @@ describe WeixinAuthorize::Client do ...@@ -19,9 +19,14 @@ describe WeixinAuthorize::Client do
end end
it "return errorcode and errormsg when appid or appsecret is invalid" do it "return errorcode and errormsg when appid or appsecret is invalid" do
$client_1 = WeixinAuthorize::Client.new("appid", "app_secret") $client_1 = WeixinAuthorize::Client.new("appid", "app_secret")
valid_info = $client_1.is_valid? valid_info = $client_1.is_valid?
expect(valid_info).to eq(false) expect(valid_info).to eq(false)
end end
it "#get_access_token should raise error if app_secret or appid is invalid" do
$client_2 = WeixinAuthorize::Client.new("appid_2", "app_secret_2")
expect{$client_2.get_access_token}.to raise_error(RuntimeError)
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment