auth

Paddy 2015-03-03 Parent:23c1a07c8a61 Child:8267e1c8bcd1

135:d30a3a12d387 Go to Latest

auth/token_test.go

Attach our Scope type to AuthCodes and Tokens. When obtaining an AuthorizationCode or Token, attach a slice of strings, each one a Scope ID, instead of just attaching the encoded string the user passes in. This will allow us to change our Scope encoding down the line, and is more conceptually faithful. Also, if an authorization request is made with an invalid scope, return the invalid_scope error.

History
     1.1 --- a/token_test.go	Fri Feb 20 22:34:43 2015 -0500
     1.2 +++ b/token_test.go	Tue Mar 03 22:18:28 2015 -0500
     1.3 @@ -28,8 +28,13 @@
     1.4  	if token1.TokenType != token2.TokenType {
     1.5  		return false, "token type", token1.TokenType, token2.TokenType
     1.6  	}
     1.7 -	if token1.Scope != token2.Scope {
     1.8 -		return false, "scope", token1.Scope, token2.Scope
     1.9 +	if len(token1.Scopes) != len(token2.Scopes) {
    1.10 +		return false, "scopes", token1.Scopes, token2.Scopes
    1.11 +	}
    1.12 +	for pos, scope := range token1.Scopes {
    1.13 +		if scope != token2.Scopes[pos] {
    1.14 +			return false, "scopes", token1.Scopes, token2.Scopes
    1.15 +		}
    1.16  	}
    1.17  	if !token1.ProfileID.Equal(token2.ProfileID) {
    1.18  		return false, "profile ID", token1.ProfileID, token2.ProfileID
    1.19 @@ -48,7 +53,7 @@
    1.20  		Created:      time.Now(),
    1.21  		ExpiresIn:    3600,
    1.22  		TokenType:    "bearer",
    1.23 -		Scope:        "scope",
    1.24 +		Scopes:       []string{"scope"},
    1.25  		ProfileID:    uuid.NewID(),
    1.26  	}
    1.27  	for _, store := range tokenStores {