Skip to content

Commit

Permalink
fix comment issue
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingSinger committed Jan 19, 2020
1 parent e146ad8 commit 4673bca
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
5 changes: 4 additions & 1 deletion filter/filter_impl/auth/accesskey_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import (
"testing"
)

import (
"github.com/stretchr/testify/assert"
)

import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
invocation2 "github.com/apache/dubbo-go/protocol/invocation"
"github.com/stretchr/testify/assert"
)

func TestDefaultAccesskeyStorage_GetAccesskeyPair(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion filter/filter_impl/auth/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (authenticator *DefaultAuthenticator) Authenticate(invocation protocol.Invo
consumer := invocation.AttachmentsByKey(constant.CONSUMER, "")
if IsEmpty(accessKeyId, false) || IsEmpty(consumer, false) ||
IsEmpty(requestTimestamp, false) || IsEmpty(originSignature, false) {
return errors.New("failed to authenticate, maybe consumer not enable the auth")
return errors.New("failed to authenticate your ak/sk, maybe the consumer has not enabled the auth")
}

accessKeyPair, err := getAccessKeyPair(invocation, url)
Expand Down
5 changes: 4 additions & 1 deletion filter/filter_impl/auth/authenticator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import (
"time"
)

import (
"github.com/stretchr/testify/assert"
)

import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/protocol/invocation"
"github.com/stretchr/testify/assert"
)

func TestDefaultAuthenticator_Authenticate(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions filter/filter_impl/auth/consumer_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func init() {
func (filter *ConsumerSignFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
logger.Infof("invoking ConsumerSign filter.")
url := invoker.GetUrl()
shouldAuth := url.GetParamBool(constant.SERVICE_AUTH_KEY, false)
if shouldAuth {
shouldSign := url.GetParamBool(constant.SERVICE_AUTH_KEY, false)
if shouldSign {
authenticator := extension.GetAuthenticator(url.GetParam(constant.AUTHENTICATOR_KEY, constant.DEFAULT_AUTHENTICATOR))
if err := authenticator.Sign(invocation, &url); err != nil {
panic(fmt.Sprintf("Sign for invocation %s # %s failed", url.ServiceKey(), invocation.MethodName()))
Expand Down
7 changes: 5 additions & 2 deletions filter/filter_impl/auth/consumer_sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import (
"testing"
)

import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
)

import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
"github.com/apache/dubbo-go/protocol/mock"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
)

func TestConsumerSignFilter_Invoke(t *testing.T) {
Expand Down
8 changes: 6 additions & 2 deletions filter/filter_impl/auth/provider_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import (
"testing"
"time"
)

import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
)

import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
"github.com/apache/dubbo-go/protocol/mock"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
)

func TestProviderAuthFilter_Invoke(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions filter/filter_impl/auth/sign_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func IsEmpty(s string, allowSpace bool) bool {
return true
}
if !allowSpace {
if strings.TrimSpace(s) == "" {
return true
}
return strings.TrimSpace(s) == ""
}
return false
}
1 change: 1 addition & 0 deletions filter/filter_impl/auth/sign_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package auth
import (
"testing"
)

import (
"github.com/stretchr/testify/assert"
)
Expand Down

0 comments on commit 4673bca

Please sign in to comment.