Skip to content

Commit 3b6fa3b

Browse files
committed
remove query package
1 parent 41e9f5e commit 3b6fa3b

File tree

4 files changed

+43
-28
lines changed

4 files changed

+43
-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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ require (
179179
github.com/mitchellh/reflectwalk v1.0.2
180180
github.com/ncw/swift v1.0.47
181181
github.com/oklog/run v1.1.0
182-
github.com/okta/okta-sdk-golang/v2 v2.12.1
182+
github.com/okta/okta-sdk-golang/v4 v4.1.2
183183
github.com/oracle/oci-go-sdk v24.3.0+incompatible
184184
github.com/ory/dockertest v3.3.5+incompatible
185185
github.com/ory/dockertest/v3 v3.10.0
@@ -232,9 +232,15 @@ require (
232232
cel.dev/expr v0.15.0 // indirect
233233
cloud.google.com/go/longrunning v0.5.7 // indirect
234234
github.com/containerd/containerd v1.7.12 // indirect
235+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
235236
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
236243
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
237-
github.com/okta/okta-sdk-golang/v4 v4.1.2 // indirect
238244
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
239245
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
240246
)
@@ -528,7 +534,6 @@ require (
528534
gopkg.in/ini.v1 v1.67.0 // indirect
529535
gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
530536
gopkg.in/resty.v1 v1.12.0 // indirect
531-
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
532537
gopkg.in/warnings.v0 v0.1.2 // indirect
533538
gopkg.in/yaml.v2 v2.4.0 // indirect
534539
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
980980
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
981981
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
982982
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
983+
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
984+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
985+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
983986
github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw=
984987
github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo=
985988
github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
@@ -1678,8 +1681,8 @@ github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0f
16781681
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
16791682
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
16801683
github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4=
1681-
github.com/jarcoal/httpmock v1.0.7 h1:d1a2VFpSdm5gtjhCPWsQHSnx8+5V3ms5431YwvmkuNk=
1682-
github.com/jarcoal/httpmock v1.0.7/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
1684+
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
1685+
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
16831686
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
16841687
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
16851688
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
@@ -1766,6 +1769,19 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
17661769
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
17671770
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
17681771
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
1772+
github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A=
1773+
github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y=
1774+
github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k=
1775+
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
1776+
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
1777+
github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
1778+
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
1779+
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
1780+
github.com/lestrrat-go/jwx v1.2.29 h1:QT0utmUJ4/12rmsVQrJ3u55bycPkKqGYuGT4tyRhxSQ=
1781+
github.com/lestrrat-go/jwx v1.2.29/go.mod h1:hU8k2l6WF0ncx20uQdOmik/Gjg6E3/wIRtXSNFeZuB8=
1782+
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
1783+
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
1784+
github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
17691785
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
17701786
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
17711787
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
@@ -1911,8 +1927,6 @@ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
19111927
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
19121928
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
19131929
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
1914-
github.com/okta/okta-sdk-golang/v2 v2.12.1 h1:U+smE7trkHSZO8Mval3Ow85dbxawO+pMAr692VZq9gM=
1915-
github.com/okta/okta-sdk-golang/v2 v2.12.1/go.mod h1:KRoAArk1H216oiRnQT77UN6JAhBOnOWkK27yA1SM7FQ=
19161930
github.com/okta/okta-sdk-golang/v4 v4.1.2 h1:gSycAYWGrvYeXBW8HakMZnNu/ptMuTvTQ/zZ7lgmtPI=
19171931
github.com/okta/okta-sdk-golang/v4 v4.1.2/go.mod h1:01oiHDXvZQHlZo1Uw084VDYwXIqJe19z34b53PBZpUY=
19181932
github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
@@ -2140,6 +2154,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
21402154
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
21412155
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
21422156
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
2157+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
21432158
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
21442159
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
21452160
github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 h1:8fDzz4GuVg4skjY2B0nMN7h6uN61EDVkuLyI2+qGHhI=
@@ -3063,8 +3078,6 @@ gopkg.in/ory-am/dockertest.v3 v3.3.4 h1:oen8RiwxVNxtQ1pRoV4e4jqh6UjNsOuIZ1NXns6j
30633078
gopkg.in/ory-am/dockertest.v3 v3.3.4/go.mod h1:s9mmoLkaGeAh97qygnNj4xWkiN7e1SKekYC6CovU+ek=
30643079
gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI=
30653080
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
3066-
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
3067-
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
30683081
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
30693082
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
30703083
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)