Skip to content

Commit

Permalink
Modify name for BitbucketInterceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
savitaashture committed Jun 4, 2020
1 parent dd1aff6 commit 68c073d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ spec:
### Bitbucket Interceptors

Bitbucket Interceptors contain logic to validate and filter webhooks that come from
Bitbucket server or cloud. Supported features include validating webhooks actually came from Bitbucket as well as
Bitbucket server and not the Bitbucket cloud. Supported features include validating webhooks actually come from Bitbucket server as well as
filtering incoming events.

To use this Interceptor as a validator, create a secret string using the method
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/triggers/v1alpha1/event_listener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type EventInterceptor struct {
GitHub *GitHubInterceptor `json:"github,omitempty"`
GitLab *GitLabInterceptor `json:"gitlab,omitempty"`
CEL *CELInterceptor `json:"cel,omitempty"`
Bitbucket *BitBucketInterceptor `json:"bitbucket,omitempty"`
Bitbucket *BitbucketInterceptor `json:"bitbucket,omitempty"`
}

// WebhookInterceptor provides a webhook to intercept and pre-process events
Expand All @@ -100,8 +100,8 @@ type WebhookInterceptor struct {
Header []v1beta1.Param `json:"header,omitempty"`
}

// BitBucketInterceptor provides a webhook to intercept and pre-process events
type BitBucketInterceptor struct {
// BitbucketInterceptor provides a webhook to intercept and pre-process events
type BitbucketInterceptor struct {
SecretRef *SecretRef `json:"secretRef,omitempty"`
EventTypes []string `json:"eventTypes,omitempty"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func TestEventListenerValidate_error(t *testing.T) {
Interceptors: []*v1alpha1.EventInterceptor{{
GitHub: &v1alpha1.GitHubInterceptor{},
GitLab: &v1alpha1.GitLabInterceptor{},
Bitbucket: &v1alpha1.BitBucketInterceptor{},
Bitbucket: &v1alpha1.BitbucketInterceptor{},
}},
}},
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/interceptors/bitbucket/bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import (
type Interceptor struct {
KubeClientSet kubernetes.Interface
Logger *zap.SugaredLogger
Bitbucket *triggersv1.BitBucketInterceptor
Bitbucket *triggersv1.BitbucketInterceptor
EventListenerNamespace string
}

func NewInterceptor(bh *triggersv1.BitBucketInterceptor, k kubernetes.Interface, ns string, l *zap.SugaredLogger) interceptors.Interceptor {
func NewInterceptor(bh *triggersv1.BitbucketInterceptor, k kubernetes.Interface, ns string, l *zap.SugaredLogger) interceptors.Interceptor {
return &Interceptor{
Logger: l,
Bitbucket: bh,
Expand Down
20 changes: 10 additions & 10 deletions pkg/interceptors/bitbucket/bitbucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
}
tests := []struct {
name string
Bitbucket *triggersv1.BitBucketInterceptor
Bitbucket *triggersv1.BitbucketInterceptor
args args
want []byte
wantErr bool
}{
{
name: "no secret",
Bitbucket: &triggersv1.BitBucketInterceptor{},
Bitbucket: &triggersv1.BitbucketInterceptor{},
args: args{
payload: ioutil.NopCloser(bytes.NewBufferString("somepayload")),
signature: "foo",
Expand All @@ -59,7 +59,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
},
{
name: "invalid header for secret",
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
SecretRef: &triggersv1.SecretRef{
SecretName: "mysecret",
SecretKey: "token",
Expand All @@ -81,7 +81,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
},
{
name: "valid header for secret",
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
SecretRef: &triggersv1.SecretRef{
SecretName: "mysecret",
SecretKey: "token",
Expand All @@ -106,7 +106,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
},
{
name: "matching event",
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
EventTypes: []string{"pr:opened", "repo:refs_changed"},
},
args: args{
Expand All @@ -118,7 +118,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
},
{
name: "no matching event",
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
EventTypes: []string{"pr:opened", "repo:refs_changed"},
},
args: args{
Expand All @@ -129,7 +129,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
},
{
name: "valid header for secret and matching event",
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
SecretRef: &triggersv1.SecretRef{
SecretName: "mysecret",
SecretKey: "token",
Expand All @@ -156,7 +156,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
},
{
name: "valid header for secret, but no matching event",
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
SecretRef: &triggersv1.SecretRef{
SecretName: "mysecret",
SecretKey: "token",
Expand All @@ -182,7 +182,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
},
{
name: "invalid header for secret, but matching event",
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
SecretRef: &triggersv1.SecretRef{
SecretName: "mysecret",
SecretKey: "token",
Expand All @@ -205,7 +205,7 @@ func TestInterceptor_ExecuteTrigger_Signature(t *testing.T) {
wantErr: true,
}, {
name: "nil body does not panic",
Bitbucket: &triggersv1.BitBucketInterceptor{},
Bitbucket: &triggersv1.BitbucketInterceptor{},
args: args{
payload: nil,
signature: "foo",
Expand Down
4 changes: 2 additions & 2 deletions pkg/sink/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ func TestHandleEventWithInterceptorsAndTriggerAuth(t *testing.T) {

}

func TestHandleEventWithBitBucketInterceptors(t *testing.T) {
func TestHandleEventWithBitbucketInterceptors(t *testing.T) {
eventBody := json.RawMessage(`{"repository": {"links": {"clone": [{"href": "testurl", "name": "ssh"}, {"href": "testurl", "name": "http"}]}}, "changes": [{"ref": {"displayId": "test-branch"}}]}`)
tb, tt := getResources(t, "$(body.repository.links.clone[1].href)")

Expand All @@ -924,7 +924,7 @@ func TestHandleEventWithBitBucketInterceptors(t *testing.T) {
Bindings: []*triggersv1.EventListenerBinding{{Name: "tb", Kind: "TriggerBinding"}},
Template: triggersv1.EventListenerTemplate{Name: "tt"},
Interceptors: []*triggersv1.EventInterceptor{{
Bitbucket: &triggersv1.BitBucketInterceptor{
Bitbucket: &triggersv1.BitbucketInterceptor{
SecretRef: &triggersv1.SecretRef{
SecretKey: "secretKey",
SecretName: "secret",
Expand Down

0 comments on commit 68c073d

Please sign in to comment.