Skip to content

Commit

Permalink
Fxied some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijamt committed Sep 3, 2023
1 parent 134f89e commit 5096e17
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
30 changes: 30 additions & 0 deletions gitlab_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,33 @@ func TestGitlabClient_CurrentTokenInfo(t *testing.T) {
require.NotNil(t, token)
assert.EqualValues(t, gitlab.TokenTypePersonal, token.TokenType)
}

func TestGitlabClient_CreateAccessToken(t *testing.T) {
var err error

server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.RequestURI == "/api/v4/personal_access_tokens/self" {
w.WriteHeader(http.StatusOK)
data, _ := os.ReadFile("testdata/personal_access_tokens_self.json")
_, _ = w.Write(data)

} else {
w.WriteHeader(http.StatusNotFound)
}
}))
defer server.Close()

var client gitlab.Client
client, err = gitlab.NewGitlabClient(&gitlab.EntryConfig{
Token: "super-secret-token",
BaseURL: server.URL,
}, nil)
require.NoError(t, err)
require.NotNil(t, client)
require.True(t, client.Valid())

token, err := client.CurrentTokenInfo()
require.NoError(t, err)
require.NotNil(t, token)
assert.EqualValues(t, gitlab.TokenTypePersonal, token.TokenType)
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,5 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf // indirect
google.golang.org/grpc v1.57.0 // indirect
gopkg.in/dnaeon/go-vcr.v3 v3.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/dnaeon/go-vcr.v3 v3.1.2 h1:F1smfXBqQqwpVifDfUBQG6zzaGjzT+EnVZakrOdr5wA=
gopkg.in/dnaeon/go-vcr.v3 v3.1.2/go.mod h1:2IMOnnlx9I6u9x+YBsM3tAMx6AlOxnJ0pWxQAzZ79Ag=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
2 changes: 1 addition & 1 deletion helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
gitlab "github.com/ilijamt/vault-plugin-secrets-gitlab"
"github.com/stretchr/testify/require"
g "github.com/xanzy/go-gitlab"
"slices"
"golang.org/x/exp/slices"
"sync"
"testing"
"time"
Expand Down

0 comments on commit 5096e17

Please sign in to comment.