Skip to content

Commit

Permalink
[chore] use status type in basicauthextension (#21278)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme authored May 1, 2023
1 parent c357c81 commit 99f333a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 6 additions & 4 deletions extension/basicauthextension/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension/internal/metadata"
)

func TestLoadConfig(t *testing.T) {
Expand All @@ -33,19 +35,19 @@ func TestLoadConfig(t *testing.T) {
expectedErr bool
}{
{
id: component.NewID(typeStr),
id: component.NewID(metadata.Type),
expectedErr: true,
},
{
id: component.NewIDWithName(typeStr, "server"),
id: component.NewIDWithName(metadata.Type, "server"),
expected: &Config{
Htpasswd: &HtpasswdSettings{
Inline: "username1:password1\nusername2:password2\n",
},
},
},
{
id: component.NewIDWithName(typeStr, "client"),
id: component.NewIDWithName(metadata.Type, "client"),
expected: &Config{
ClientAuth: &ClientAuthSettings{
Username: "username",
Expand All @@ -54,7 +56,7 @@ func TestLoadConfig(t *testing.T) {
},
},
{
id: component.NewIDWithName(typeStr, "both"),
id: component.NewIDWithName(metadata.Type, "both"),
expectedErr: true,
},
}
Expand Down
6 changes: 1 addition & 5 deletions extension/basicauthextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension/internal/metadata"
)

const (
typeStr = "basicauth"
)

// NewFactory creates a factory for the static bearer token Authenticator extension.
func NewFactory() extension.Factory {
return extension.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
createExtension,
metadata.Stability,
Expand Down
4 changes: 3 additions & 1 deletion extension/basicauthextension/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/extension/extensiontest"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension/internal/metadata"
)

func TestCreateDefaultConfig(t *testing.T) {
Expand Down Expand Up @@ -54,5 +56,5 @@ func TestCreateExtension_ValidConfig(t *testing.T) {
func TestNewFactory(t *testing.T) {
f := NewFactory()
assert.NotNil(t, f)
assert.Equal(t, f.Type(), component.Type(typeStr))
assert.Equal(t, f.Type(), component.Type(metadata.Type))
}

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

2 changes: 1 addition & 1 deletion extension/basicauthextension/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: basicauthextension
type: basicauth

status:
class: extension
Expand Down

0 comments on commit 99f333a

Please sign in to comment.