Skip to content

Commit 6dec2b1

Browse files
use key instead of token for hex org
1 parent 2b4f6d0 commit 6dec2b1

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

internal/handlers/hex_organization.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type HexOrganizationHandler struct {
1818

1919
type hexOrganizationCredentials struct {
2020
organization string
21-
token string
21+
key string
2222
}
2323

2424
// NewHexOrganizationHandler returns a new HexOrganizationHandler.
@@ -31,14 +31,14 @@ func NewHexOrganizationHandler(creds config.Credentials) *HexOrganizationHandler
3131
}
3232

3333
org := cred.GetString("organization")
34-
token := cred.GetString("token")
35-
if org == "" || token == "" {
34+
key := cred.GetString("key")
35+
if org == "" || key == "" {
3636
continue
3737
}
3838

3939
hexCred := hexOrganizationCredentials{
4040
organization: org,
41-
token: token,
41+
key: key,
4242
}
4343
handler.credentials = append(handler.credentials, hexCred)
4444
}
@@ -65,7 +65,7 @@ func (h *HexOrganizationHandler) HandleRequest(req *http.Request, ctx *goproxy.P
6565
for _, cred := range h.credentials {
6666
if cred.organization == reqOrg {
6767
logging.RequestLogf(ctx, "* authenticating hex request (org: %s)", reqOrg)
68-
req.Header.Set("authorization", cred.token)
68+
req.Header.Set("authorization", cred.key)
6969
return req, nil
7070
}
7171
}

internal/handlers/hex_organization_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ import (
88
)
99

1010
func TestHexOrganizationHandler(t *testing.T) {
11-
dependabotToken := "123"
12-
deltaForceToken := "456"
11+
dependabotKey := "123"
12+
deltaForceKey := "456"
1313
credentials := config.Credentials{
1414
config.Credential{
1515
"type": "hex_organization",
1616
"organization": "dependabot",
17-
"token": dependabotToken,
17+
"key": dependabotKey,
1818
},
1919
config.Credential{
2020
"type": "hex_organization",
2121
"organization": "deltaforce",
22-
"token": deltaForceToken,
22+
"key": deltaForceKey,
2323
},
2424
}
2525
handler := NewHexOrganizationHandler(credentials)
2626

2727
req := httptest.NewRequest("GET", "https://repo.hex.pm/repos/dependabot/packages/foo", nil)
2828
req = handleRequestAndClose(handler, req, nil)
29-
assertHasTokenAuth(t, req, "", dependabotToken, "dependabot registry request")
29+
assertHasTokenAuth(t, req, "", dependabotKey, "dependabot registry request")
3030

3131
req = httptest.NewRequest("GET", "https://repo.hex.pm/repos/deltaforce/packages/foo", nil)
3232
req = handleRequestAndClose(handler, req, nil)
33-
assertHasTokenAuth(t, req, "", deltaForceToken, "deltaforce registry request")
33+
assertHasTokenAuth(t, req, "", deltaForceKey, "deltaforce registry request")
3434

3535
// Not an org
3636
req = httptest.NewRequest("GET", "https://repo.hex.pm/packages/foo", nil)

0 commit comments

Comments
 (0)