Skip to content

Commit

Permalink
remove check for google key
Browse files Browse the repository at this point in the history
  • Loading branch information
aliok committed Jun 7, 2018
1 parent df1e6ac commit 863e5c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 51 deletions.
34 changes: 15 additions & 19 deletions pkg/configOperator/configOperator.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,27 +200,23 @@ func (op ConfigOperator) handleAndroidVariant(secret *BindingSecret) {
serviceBindingId := string(secret.Data[constants.BindingDataServiceBindingIdKey])
serviceInstanceName := string(secret.Data[constants.BindingDataServiceInstanceNameKey])

if op.pushClient.hasAndroidVariant(googleKey) == nil {
payload := &AndroidVariant{
ProjectNumber: projectNumber,
GoogleKey: googleKey,
Variant: Variant{
Name: clientId,
VariantID: uuid.NewV4().String(),
Secret: uuid.NewV4().String(),
},
}
payload := &AndroidVariant{
ProjectNumber: projectNumber,
GoogleKey: googleKey,
Variant: Variant{
Name: clientId,
VariantID: uuid.NewV4().String(),
Secret: uuid.NewV4().String(),
},
}

log.Print("Creating a new android variant", payload)
success, variant := op.pushClient.createAndroidVariant(payload)
if success {
config, _ := variant.getJson()
op.updateConfiguration("android", clientId, variant.VariantID, config, serviceBindingId, serviceInstanceName)
} else {
log.Println("No variant has been created in UPS, skipping config secret")
}
log.Print("Creating a new android variant", payload)
success, variant := op.pushClient.createAndroidVariant(payload)
if success {
config, _ := variant.getJson()
op.updateConfiguration("android", clientId, variant.VariantID, config, serviceBindingId, serviceInstanceName)
} else {
log.Printf("A variant for google key '%s' already exists", googleKey)
log.Println("No variant has been created in UPS, skipping config secret")
}
}

Expand Down
32 changes: 0 additions & 32 deletions pkg/configOperator/configOperator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/stretchr/testify/mock"
"reflect"
"github.com/stretchr/testify/assert"
)

var op *ConfigOperator;
Expand Down Expand Up @@ -157,37 +156,6 @@ func TestConfigOperator_handleDeleteSecret_whenThereIs1Variant(t *testing.T) {
kubeHelper.AssertNotCalled(t, "updateSecret", mock.Anything)
}

func TestConfigOperator_handleAddSecret_whenAndroid_andAVariantExistsWithSameGoogleKey(t *testing.T) {
setup()

bindingSecret := BindingSecret{
Data: map[string][]byte{
"appType": []byte("Android"),
"googleKey": []byte("myGoogleKey"),
},
}
bindingSecret.Labels = map[string]string{
"secretType": "mobile-client-binding-secret",
}
bindingSecret.Name = "myBindingSecret"

pushClient.On("hasAndroidVariant", "myGoogleKey").Return(&AndroidVariant{
GoogleKey: "myGoogleKey",
})

kubeHelper.On("deleteSecret", "myBindingSecret").Once()

op.handleAddSecret(&bindingSecret)

assert.Empty(t, annotationHelper.Calls)

kubeHelper.AssertNotCalled(t, "createClientConfigSecret", mock.Anything)
kubeHelper.AssertNotCalled(t, "updateSecret", mock.Anything)

kubeHelper.AssertExpectations(t)
annotationHelper.AssertExpectations(t)
}

func TestConfigOperator_handleAddSecret_whenAndroid_andNoVariantExistsWithSameGoogleKey(t *testing.T) {
setup()

Expand Down

0 comments on commit 863e5c9

Please sign in to comment.