-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from paketo-buildpacks/jtc/support-keys-withou…
…t-hyphens Support token and url keys without hyphens
- Loading branch information
Showing
10 changed files
with
181 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ bin/ | |
dependencies/ | ||
package/ | ||
scratch/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2018-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dt_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/buildpacks/libcnb" | ||
. "github.com/onsi/gomega" | ||
"github.com/sclevine/spec" | ||
|
||
"github.com/paketo-buildpacks/dynatrace/v4/dt" | ||
) | ||
|
||
var createBinding = func(keysAndValues ...string) libcnb.Binding { | ||
secrets := make(map[string]string, len(keysAndValues)/2) | ||
|
||
for i := 0; i < len(keysAndValues); i = i + 2 { | ||
secrets[keysAndValues[i]] = keysAndValues[i+1] | ||
} | ||
|
||
return libcnb.Binding{Secret: secrets} | ||
} | ||
|
||
func testBaseURI(t *testing.T, _ spec.G, it spec.S) { | ||
var ( | ||
Expect = NewWithT(t).Expect | ||
) | ||
|
||
it("uses api-url", func() { | ||
Expect(dt.BaseURI(createBinding("api-url", "test-url"))). | ||
To(Equal("test-url")) | ||
}) | ||
|
||
it("uses api-url when both api-url and apiurl are set", func() { | ||
Expect(dt.BaseURI(createBinding("api-url", "test-url", "apiurl", "other-url"))). | ||
To(Equal("test-url")) | ||
}) | ||
|
||
it("uses apiurl", func() { | ||
Expect(dt.BaseURI(createBinding("apiurl", "other-url"))). | ||
To(Equal("other-url")) | ||
}) | ||
|
||
it("uses environment-id", func() { | ||
Expect(dt.BaseURI(createBinding("environment-id", "test-id"))). | ||
To(Equal("https://test-id.live.dynatrace.com/api")) | ||
}) | ||
} | ||
|
||
func testAPIToken(t *testing.T, _ spec.G, it spec.S) { | ||
var ( | ||
Expect = NewWithT(t).Expect | ||
) | ||
|
||
it("uses api-token", func() { | ||
Expect(dt.APIToken(createBinding("api-token", "test-token"))). | ||
To(Equal("test-token")) | ||
}) | ||
|
||
it("uses api-token when both api-token and apitoken are set", func() { | ||
Expect(dt.APIToken(createBinding("api-token", "test-token", "apitoken", "other-token"))). | ||
To(Equal("test-token")) | ||
}) | ||
|
||
it("uses apitoken", func() { | ||
Expect(dt.APIToken(createBinding("apitoken", "other-token"))). | ||
To(Equal("other-token")) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters