Merge lp:~rvb/gwacl/signed-access into lp:gwacl
Proposed by
Raphaël Badin
Status: | Merged |
---|---|
Approved by: | Raphaël Badin |
Approved revision: | 206 |
Merged at revision: | 202 |
Proposed branch: | lp:~rvb/gwacl/signed-access |
Merge into: | lp:gwacl |
Diff against target: |
256 lines (+201/-3) 4 files modified
shared_signature.go (+74/-0) shared_signature_test.go (+70/-0) storage_base.go (+19/-3) storage_base_test.go (+38/-0) |
To merge this branch: | bzr merge lp:~rvb/gwacl/signed-access |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julian Edwards (community) | Approve | ||
Review via email: mp+176732@code.launchpad.net |
Commit message
Add support for the Windows Azure Shared Access Signature URL mechanism.
Description of the change
This branch adds support for the Windows Azure Shared Access Signature URL mechanism. More specifically, it adds a way to get an anonymously-
See http://
To post a comment you must log in.
Nice branch, reasonably well tested, but I think we should improve some of that testing!
In particular, the new sign() method is not unit tested. I think you should add a test for it, and then we can use that function in other tests like TestComposeShar edSignature so that we don't have to hard-code the magic string "COJt8UagHJR2LB T1129bhDChtgfLG FqfZ0YQpBdF0= " which makes the test difficult to verify what it's actually testing.
Ok so on to the details:
16 +func composeSharedSi gnature( permission, signedExpiry, path, accountName, signedIdentifier, signedVersion, accountKey string) string {
Since you documented the other internal compose* funcs, can you do the same here please.
19 + stringToSign := fmt.Sprintf( "%s\n%s\ n%s\n%s\ n%s\n%s" , source, signedIdentifier, signedVersion)
20 + permission, "", signedExpiry, canonicalizedRe
Gah I *really* miss Python's format() here. The second arg of "" is a bit magic, can you initalise a variable called 'signedStart' to "" and then use it instead of the bare "", it will make that Sprintf more readable (the "" sticks out like a pimple on a supermodel).
29 +func composeAccessQu eryString( permission, signedExpiry, path, accountName, signedIdentifier, signedVersion, signedRessource, accountKey string) url.Values {
Given that this shares almost all of its params with composeSharedSi gnature it might be worth declaring a struct type which encapsulates the data in a shared access signature. I think once functions get beyond more than three params they get very unwieldy very quickly. The new type could well be useful in the future if we do more things with SASes.
Also this function is mis-named, it is not composing a string. May I suggest composeAcessQue ryValues instead.
+func composeReadBlob Values( container, filename, accountName, accountKey string, expires time.Time) url.Values { UTC().Format( time.RFC3339)
45 + expiryDateString := expires.
Christ - why did they not make the date header format and this expiry stamp consistent? :/ (The other is RFC1123)
71 +func (*sharedSignatu reSuite) TestComposeShar edSignature( c *C) { StdEncoding. EncodeToString( []byte( "key")) gnature( permission, signedExpiry, path, accountName, signedIdentifier, signedVersion, accountKey) LBT1129bhDChtgf LGFqfZ0YQpBdF0= ")
72 + permission := "r"
73 + signedExpiry := "2015-02-12"
74 + path := "/path/to/file"
75 + accountName := "name"
76 + signedIdentifier := "identifier"
77 + signedVersion := "2012-02-12"
78 + accountKey := base64.
79 +
80 + signature := composeSharedSi
81 + c.Check(signature, Equals, "C/COJt8UagHJR2
Here, once sign() is independently tested, you can use its return value instead of hard-coding this string here. The test will improve in readability for that.
103 +func (*sharedSignatu reSuite) TestComposeRead BlobValues( c *C) { StdEncoding. EncodeToString( []byte( "key")) Values( container, filename, accountName, accountKey, expires) values. Get("sv" ), Equals, "2012-02-12")
104 + container := "container"
105 + filename := "/path/to/file"
106 + accountName := "name"
107 + accountKey := base64.
108 + expires := time.Now()
109 + values := composeReadBlob
110 + c.Check(
111 + ...