Skip to content

Commit 57bed20

Browse files
committed
remove query package
1 parent 18edee3 commit 57bed20

File tree

4 files changed

+42
-28
lines changed

4 files changed

+42
-28
lines changed

builtin/credential/okta/backend_test.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/hashicorp/vault/sdk/helper/policyutil"
1919
"github.com/hashicorp/vault/sdk/logical"
2020
"github.com/okta/okta-sdk-golang/v4/okta"
21-
"github.com/okta/okta-sdk-golang/v4/okta/query"
2221
"github.com/stretchr/testify/require"
2322
)
2423

@@ -115,15 +114,15 @@ func TestBackend_Config(t *testing.T) {
115114

116115
func createOktaGroups(t *testing.T, username string, token string, org string) []string {
117116
orgURL := "https://" + org + "." + previewBaseURL
118-
ctx, client, err := okta.NewClient(context.Background(), okta.WithOrgUrl(orgURL), okta.WithToken(token))
117+
cfg, err := okta.NewConfiguration(okta.WithOrgUrl(orgURL), okta.WithToken(token))
119118
require.Nil(t, err)
119+
client := okta.NewAPIClient(cfg)
120+
ctx := context.Background()
120121

121-
users, _, err := client.User.ListUsers(ctx, &query.Params{
122-
Q: username,
123-
})
122+
users, _, err := client.UserAPI.ListUsers(ctx).Filter(username).Execute()
124123
require.Nil(t, err)
125124
require.Len(t, users, 1)
126-
userID := users[0].Id
125+
userID := users[0].GetId()
127126
var groupIDs []string
128127

129128
// Verify that login's call to list the groups of the user logging in will page
@@ -133,38 +132,37 @@ func createOktaGroups(t *testing.T, username string, token string, org string) [
133132
// only 200 results are returned for most orgs."
134133
for i := 0; i < 201; i++ {
135134
name := fmt.Sprintf("TestGroup%d", i)
136-
groups, _, err := client.Group.ListGroups(ctx, &query.Params{
137-
Q: name,
138-
})
135+
groups, _, err := client.GroupAPI.ListGroups(ctx).Filter(name).Execute()
139136
require.Nil(t, err)
140137

141138
var groupID string
142139
if len(groups) == 0 {
143-
group, _, err := client.Group.CreateGroup(ctx, okta.Group{
140+
group, _, err := client.GroupAPI.CreateGroup(ctx).Group(okta.Group{
144141
Profile: &okta.GroupProfile{
145-
Name: fmt.Sprintf("TestGroup%d", i),
142+
Name: okta.PtrString(fmt.Sprintf("TestGroup%d", i)),
146143
},
147-
})
144+
}).Execute()
148145
require.Nil(t, err)
149-
groupID = group.Id
146+
groupID = group.GetId()
150147
} else {
151-
groupID = groups[0].Id
148+
groupID = groups[0].GetId()
152149
}
153150
groupIDs = append(groupIDs, groupID)
154151

155-
_, err = client.Group.AddUserToGroup(ctx, groupID, userID)
152+
_, err = client.GroupAPI.AssignUserToGroup(ctx, groupID, userID).Execute()
156153
require.Nil(t, err)
157154
}
158155
return groupIDs
159156
}
160157

161158
func deleteOktaGroups(t *testing.T, token string, org string, groupIDs []string) {
162159
orgURL := "https://" + org + "." + previewBaseURL
163-
ctx, client, err := okta.NewClient(context.Background(), okta.WithOrgUrl(orgURL), okta.WithToken(token))
160+
cfg, err := okta.NewConfiguration(okta.WithOrgUrl(orgURL), okta.WithToken(token))
164161
require.Nil(t, err)
162+
client := okta.NewAPIClient(cfg)
165163

166164
for _, groupID := range groupIDs {
167-
_, err := client.Group.DeleteGroup(ctx, groupID)
165+
_, err := client.GroupAPI.DeleteGroup(context.Background(), groupID).Execute()
168166
require.Nil(t, err)
169167
}
170168
}

go.mod

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ require (
178178
github.com/mitchellh/reflectwalk v1.0.2
179179
github.com/ncw/swift v1.0.47
180180
github.com/oklog/run v1.1.0
181-
github.com/okta/okta-sdk-golang/v2 v2.12.1
181+
github.com/okta/okta-sdk-golang/v4 v4.1.2
182182
github.com/oracle/oci-go-sdk v24.3.0+incompatible
183183
github.com/ory/dockertest v3.3.5+incompatible
184184
github.com/ory/dockertest/v3 v3.10.0
@@ -234,12 +234,17 @@ require (
234234
github.com/containerd/containerd v1.7.20 // indirect
235235
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
236236
github.com/hashicorp/go-secure-stdlib/httputil v0.1.0 // indirect
237+
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
238+
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
239+
github.com/lestrrat-go/httpcc v1.0.1 // indirect
240+
github.com/lestrrat-go/iter v1.0.2 // indirect
241+
github.com/lestrrat-go/jwx v1.2.29 // indirect
242+
github.com/lestrrat-go/option v1.0.1 // indirect
237243
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
238244
github.com/moby/docker-image-spec v1.3.1 // indirect
239245
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
240246
github.com/x448/float16 v0.8.4 // indirect
241247
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
242-
github.com/okta/okta-sdk-golang/v4 v4.1.2 // indirect
243248
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
244249
)
245250

@@ -532,7 +537,6 @@ require (
532537
gopkg.in/ini.v1 v1.67.0 // indirect
533538
gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
534539
gopkg.in/resty.v1 v1.12.0 // indirect
535-
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
536540
gopkg.in/warnings.v0 v0.1.2 // indirect
537541
gopkg.in/yaml.v2 v2.4.0 // indirect
538542
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
976976
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
977977
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
978978
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
979+
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
980+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
981+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
979982
github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw=
980983
github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo=
981984
github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
@@ -1675,8 +1678,8 @@ github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0f
16751678
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
16761679
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
16771680
github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4=
1678-
github.com/jarcoal/httpmock v1.0.7 h1:d1a2VFpSdm5gtjhCPWsQHSnx8+5V3ms5431YwvmkuNk=
1679-
github.com/jarcoal/httpmock v1.0.7/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
1681+
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
1682+
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
16801683
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
16811684
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
16821685
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
@@ -1763,6 +1766,19 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
17631766
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
17641767
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
17651768
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
1769+
github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A=
1770+
github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y=
1771+
github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k=
1772+
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
1773+
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
1774+
github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
1775+
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
1776+
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
1777+
github.com/lestrrat-go/jwx v1.2.29 h1:QT0utmUJ4/12rmsVQrJ3u55bycPkKqGYuGT4tyRhxSQ=
1778+
github.com/lestrrat-go/jwx v1.2.29/go.mod h1:hU8k2l6WF0ncx20uQdOmik/Gjg6E3/wIRtXSNFeZuB8=
1779+
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
1780+
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
1781+
github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
17661782
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
17671783
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
17681784
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
@@ -1910,8 +1926,6 @@ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
19101926
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
19111927
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
19121928
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
1913-
github.com/okta/okta-sdk-golang/v2 v2.12.1 h1:U+smE7trkHSZO8Mval3Ow85dbxawO+pMAr692VZq9gM=
1914-
github.com/okta/okta-sdk-golang/v2 v2.12.1/go.mod h1:KRoAArk1H216oiRnQT77UN6JAhBOnOWkK27yA1SM7FQ=
19151929
github.com/okta/okta-sdk-golang/v4 v4.1.2 h1:gSycAYWGrvYeXBW8HakMZnNu/ptMuTvTQ/zZ7lgmtPI=
19161930
github.com/okta/okta-sdk-golang/v4 v4.1.2/go.mod h1:01oiHDXvZQHlZo1Uw084VDYwXIqJe19z34b53PBZpUY=
19171931
github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
@@ -2141,6 +2155,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
21412155
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
21422156
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
21432157
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
2158+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
21442159
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
21452160
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
21462161
github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 h1:8fDzz4GuVg4skjY2B0nMN7h6uN61EDVkuLyI2+qGHhI=
@@ -3067,8 +3082,6 @@ gopkg.in/ory-am/dockertest.v3 v3.3.4 h1:oen8RiwxVNxtQ1pRoV4e4jqh6UjNsOuIZ1NXns6j
30673082
gopkg.in/ory-am/dockertest.v3 v3.3.4/go.mod h1:s9mmoLkaGeAh97qygnNj4xWkiN7e1SKekYC6CovU+ek=
30683083
gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI=
30693084
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
3070-
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
3071-
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
30723085
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
30733086
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
30743087
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=

vault/login_mfa.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,8 +2074,7 @@ func (c *Core) validateOkta(ctx context.Context, mConfig *mfa.Config, username s
20742074
// the VerifyFactor respone. This code effectively reimplements that method.
20752075
// client.UserFactorAPI.GetFactorTransactionStatus(client.GetConfig().Context, user.GetId(), userFactor.GetId())
20762076

2077-
client.
2078-
req, err := rq.WithAccept("application/json").WithContentType("application/json").NewRequest("GET", url.String(), nil)
2077+
req, err := rq.WithAccept("application/json").WithContentType("application/json").NewRequest("GET", url.String(), nil)
20792078
if err != nil {
20802079
return err
20812080
}

0 commit comments

Comments
 (0)