Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Return fully qualified subscription name #11

Merged
merged 3 commits into from Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
20170307-03
20170316-01
5 changes: 5 additions & 0 deletions auth.go
Expand Up @@ -76,6 +76,11 @@ func FindAuth(ctx context.Context, id string) (*Auth, error) {

func FindAuthWithToken(ctx context.Context, token string) (*Auth, error) {
parts := strings.SplitN(token, ":", 2)
if len(parts) != 2 {
err := errors.New("Invalid token: " + token)
log.Errorf(ctx, "@FindAuthWithToken %v", err)
return nil, err
}
id := parts[0]
pw := parts[1]
auth, err := FindAuth(ctx, id)
Expand Down
6 changes: 4 additions & 2 deletions handler_test.go
Expand Up @@ -20,7 +20,8 @@ const (
)

func TestActions(t *testing.T) {
inst, err := aetest.NewInstance(nil)
opt := &aetest.Options{StronglyConsistentDatastore: true}
inst, err := aetest.NewInstance(opt)
assert.NoError(t, err)
defer inst.Close()

Expand Down Expand Up @@ -49,6 +50,7 @@ func TestActions(t *testing.T) {
auth_headers := []string{
"",
"Bearer ",
"Bearer invalid-token",
"Bearer invalid-token:123456789",
}
for _, v := range auth_headers {
Expand Down Expand Up @@ -240,7 +242,7 @@ func TestActions(t *testing.T) {
if assert.Equal(t, 1, len(subscriptions)) {
sub := subscriptions[0]
assert.Equal(t, "pipeline01", sub.Pipeline)
assert.Equal(t, "pipeline01-progress-subscription", sub.Name)
assert.Equal(t, "projects/proj-123/subscriptions/pipeline01-progress-subscription", sub.Name)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline.go
Expand Up @@ -194,7 +194,7 @@ func GetActiveSubscriptions(ctx context.Context) ([]*Subscription, error) {
for _, pipeline := range pipelines {
r = append(r, &Subscription{
Pipeline: pipeline.Props.Name,
Name: pipeline.Props.Name + "-progress-subscription",
Name: fmt.Sprintf("projects/%v/subscriptions/%v-progress-subscription", pipeline.Props.ProjectID, pipeline.Props.Name),
})
}
return r, nil
Expand Down