mirror of
https://gitee.com/yadong.zhang/JustAuth.git
synced 2026-01-07 19:31:48 +08:00
Add unit tests for me.zhyd.oauth.utils.GlobalAuthUtil
These tests were written using Diffblue Cover.
This commit is contained in:
parent
41a52767b3
commit
e03088a9b4
56
src/test/java/me/zhyd/oauth/utils/GlobalAuthUtilTest.java
Normal file
56
src/test/java/me/zhyd/oauth/utils/GlobalAuthUtilTest.java
Normal file
@ -0,0 +1,56 @@
|
||||
package me.zhyd.oauth.utils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GlobalAuthUtilTest {
|
||||
|
||||
@Test
|
||||
public void testGenerateDingTalkSignature() {
|
||||
Assert.assertEquals("mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe%2FNis5lq9ik%3D",
|
||||
GlobalAuthUtil.generateDingTalkSignature(
|
||||
"SHA-256", "1562325753000 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrlDecode() {
|
||||
Assert.assertEquals("", GlobalAuthUtil.urlDecode(null));
|
||||
Assert.assertEquals("https://www.foo.bar",
|
||||
GlobalAuthUtil.urlDecode("https://www.foo.bar"));
|
||||
Assert.assertEquals("mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe/Nis5lq9ik=",
|
||||
GlobalAuthUtil.urlDecode(
|
||||
"mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe%2FNis5lq9ik%3D"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseStringToMap() {
|
||||
Assert.assertEquals("{bar=baz}",
|
||||
GlobalAuthUtil.parseStringToMap("foo&bar=baz"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsHttpProtocol() {
|
||||
Assert.assertFalse(GlobalAuthUtil.isHttpProtocol(""));
|
||||
Assert.assertFalse(GlobalAuthUtil.isHttpProtocol("foo"));
|
||||
|
||||
Assert.assertTrue(GlobalAuthUtil.isHttpProtocol("http://www.foo.bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsHttpsProtocol() {
|
||||
Assert.assertFalse(GlobalAuthUtil.isHttpsProtocol(""));
|
||||
Assert.assertFalse(GlobalAuthUtil.isHttpsProtocol("foo"));
|
||||
|
||||
Assert.assertTrue(
|
||||
GlobalAuthUtil.isHttpsProtocol("https://www.foo.bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLocalHost() {
|
||||
Assert.assertFalse(GlobalAuthUtil.isLocalHost("foo"));
|
||||
|
||||
Assert.assertTrue(GlobalAuthUtil.isLocalHost(""));
|
||||
Assert.assertTrue(GlobalAuthUtil.isLocalHost("127.0.0.1"));
|
||||
Assert.assertTrue(GlobalAuthUtil.isLocalHost("localhost"));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user