-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
common: trim tailing zero when calculating sign for double and float (#…
…40)
- Loading branch information
Showing
32 changed files
with
173 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.9-release | ||
1.1.0-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,82 @@ public void verifyAc() throws UCloudException { | |
|
||
assertEquals("cba5cf5ec4d4233d206b1b54951e3787350a642f", cred.verifyAc(request)); | ||
} | ||
|
||
static class DoubleRequest extends Request { | ||
DoubleRequest() { super(); } | ||
|
||
@UCloudParam("Proportion") | ||
private Double proportion; | ||
|
||
@UCloudParam("Region") | ||
private String region; | ||
|
||
public String getRegion() { | ||
return region; | ||
} | ||
|
||
public void setRegion(String region) { | ||
this.region = region; | ||
} | ||
|
||
public void setProportion(Double proportion) { | ||
this.proportion = proportion; | ||
} | ||
|
||
public Double getProportion() { | ||
return proportion; | ||
} | ||
} | ||
|
||
@Test | ||
public void verifyAcDoubleTailingZero() throws UCloudException { | ||
Credential cred = new Credential(pubKey, priKey); | ||
Assert.assertEquals(pubKey, cred.getPublicKey()); | ||
Assert.assertEquals(priKey, cred.getPrivateKey()); | ||
|
||
cred.setPublicKey(pubKey); | ||
cred.setPrivateKey(priKey); | ||
Assert.assertEquals(pubKey, cred.getPublicKey()); | ||
Assert.assertEquals(priKey, cred.getPrivateKey()); | ||
|
||
DoubleRequest request = new DoubleRequest(); | ||
request.setAction("DescribeUHostInstance"); | ||
request.setRegion("cn-bj2"); | ||
request.setProportion(35.0); | ||
|
||
String ac0 = cred.verifyAc(request); | ||
|
||
// You can calculate sign by: | ||
// ucloud sign --private-key 46f09bb9fab4f12dfc160dae12273d5332b5debe \ | ||
// --param Action=DescribeUHostInstance --param Region=cn-bj2 \ | ||
// --param Proportion=35 \ | ||
// --param [email protected] | ||
assertEquals("da620b97de476947302291fc93a2d8b0710be328", ac0); | ||
} | ||
|
||
@Test | ||
public void verifyAcDoubleNoneTailingZero() throws UCloudException { | ||
Credential cred = new Credential(pubKey, priKey); | ||
Assert.assertEquals(pubKey, cred.getPublicKey()); | ||
Assert.assertEquals(priKey, cred.getPrivateKey()); | ||
|
||
cred.setPublicKey(pubKey); | ||
cred.setPrivateKey(priKey); | ||
Assert.assertEquals(pubKey, cred.getPublicKey()); | ||
Assert.assertEquals(priKey, cred.getPrivateKey()); | ||
|
||
DoubleRequest request = new DoubleRequest(); | ||
request.setAction("DescribeUHostInstance"); | ||
request.setRegion("cn-bj2"); | ||
request.setProportion(65.722); | ||
|
||
String ac0 = cred.verifyAc(request); | ||
|
||
// You can calculate sign by: | ||
// ucloud sign --private-key 46f09bb9fab4f12dfc160dae12273d5332b5debe \ | ||
// --param Action=DescribeUHostInstance --param Region=cn-bj2 \ | ||
// --param Proportion=65.722 \ | ||
// --param [email protected] | ||
assertEquals("5e39dd48144d6a075328e56a6c5e9df6c39ae939", ac0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.