Skip to content

Commit

Permalink
prep release v4
Browse files Browse the repository at this point in the history
  • Loading branch information
duytiennguyen-okta committed Feb 9, 2024
1 parent d58f63b commit caf1c8d
Show file tree
Hide file tree
Showing 14 changed files with 21,389 additions and 6,217 deletions.
10 changes: 4 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ jobs:
name: "test stage"
command: make test

test-v3:
test-v4:
docker:
- image: cimg/go:1.19.4
steps:
- checkout
- run: go version
- platform-orb/step-load-dependencies
- run:
name: "test stage"
command: |
cd okta/v3
go mod download
go test -failfast -race ./ -test.v
command: make v4-test

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
Expand All @@ -44,7 +42,7 @@ workflows:
- test-v2:
requires:
- cache-secrets
# - test-v3:
# - test-v4:
# requires:
# - cache-secrets
# See OKTA-624790
Expand Down
6 changes: 3 additions & 3 deletions .generator/config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
generatorName: go
templateDir: ./.generator/templates
outputDir: ./okta/v3
outputDir: ./okta/v4
gitUserId: okta
gitRepoId: okta-sdk-golang
versionName: v3
versionName: v4
additionalProperties:
enumClassPrefix: true
generateInterfaces: true
packageName: okta
packageVersion: 3.0.19
packageVersion: 4.0.0
useOneOfDiscriminatorLookup: true
disallowAdditionalPropertiesIfNotPresent: false
files:
Expand Down
2,446 changes: 2,318 additions & 128 deletions .generator/okta-management-APIs-oasv3-enum-inheritance.yaml

Large diffs are not rendered by default.

25,024 changes: 19,019 additions & 6,005 deletions .generator/okta-management-APIs-oasv3-noEnums-inheritance.yaml

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions .generator/templates/api_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ func Test_Activate_Application(t *testing.T) {
app, _, err := apiClient.ApplicationAPI.GetApplication(apiClient.cfg.Context, createdApp.BasicAuthApplication.GetId()).Execute()
require.NoError(t, err, "Could not get app by ID")
assert.Equal(t, createdApp.BasicAuthApplication.GetId(), app.BasicAuthApplication.GetId())
assert.Equal(t, APPLICATIONLIFECYCLESTATUS_INACTIVE, app.BasicAuthApplication.GetStatus())
assert.Equal(t, "INACTIVE", app.BasicAuthApplication.GetStatus())
})
t.Run("activate applications", func(t *testing.T) {
_, err = apiClient.ApplicationAPI.ActivateApplication(apiClient.cfg.Context, createdApp.BasicAuthApplication.GetId()).Execute()
require.NoError(t, err, "Could not activate the app")
newapp, _, err := apiClient.ApplicationAPI.GetApplication(apiClient.cfg.Context, createdApp.BasicAuthApplication.GetId()).Execute()
require.NoError(t, err, "Could not get app by ID")
assert.Equal(t, createdApp.BasicAuthApplication.GetId(), newapp.BasicAuthApplication.GetId())
assert.Equal(t, APPLICATIONLIFECYCLESTATUS_ACTIVE, newapp.BasicAuthApplication.GetStatus())
assert.Equal(t, "ACTIVE", newapp.BasicAuthApplication.GetStatus())
})
err = cleanUpApplication(createdApp.BasicAuthApplication.GetId())
require.NoError(t, err, "Clean up app should not error")
Expand Down Expand Up @@ -279,17 +279,18 @@ func TestGetDefaultProvisioningConnectionForApplication(t *testing.T) {
t.Run("get provisioning", func(t *testing.T) {
conn, _, err := apiClient.ApplicationConnectionsAPI.GetDefaultProvisioningConnectionForApplication(apiClient.cfg.Context, createdApp.SamlApplication.GetId()).Execute()
require.NoError(t, err, "getting default provisioning connection for application should not error.")
assert.NotEmpty(t, conn.GetAuthScheme())
assert.NotEmpty(t, conn.GetStatus())
assert.NotEmpty(t, conn.ProvisioningConnectionToken.GetAuthScheme())
assert.NotEmpty(t, conn.ProvisioningConnectionToken.GetStatus())
})
t.Run("set provisioning", func(t *testing.T) {
profile := ProvisioningConnectionProfile{}
profile := ProvisioningConnectionProfileToken{}
profile.SetAuthScheme("TOKEN")
profile.SetToken("TEST")
payload := ProvisioningConnectionRequest{Profile: profile}
conn, _, err := apiClient.ApplicationConnectionsAPI.UpdateDefaultProvisioningConnectionForApplication(apiClient.cfg.Context, createdApp.SamlApplication.GetId()).ProvisioningConnectionRequest(payload).Activate(false).Execute()
request := NewProvisioningConnectionTokenRequest(profile)
payload := UpdateDefaultProvisioningConnectionForApplicationRequest{ProvisioningConnectionTokenRequest: request}
conn, _, err := apiClient.ApplicationConnectionsAPI.UpdateDefaultProvisioningConnectionForApplication(apiClient.cfg.Context, createdApp.SamlApplication.GetId()).UpdateDefaultProvisioningConnectionForApplicationRequest(payload).Activate(false).Execute()
require.NoError(t, err, "setting default provisioning connection for application should not error.")
assert.Equal(t, PROVISIONINGCONNECTIONAUTHSCHEME_TOKEN, conn.GetAuthScheme())
assert.Equal(t, "TOKEN", conn.GetAuthScheme())
})
err = cleanUpApplication(createdApp.SamlApplication.GetId())
require.NoError(t, err, "Clean up app should not error")
Expand Down
6 changes: 3 additions & 3 deletions .generator/templates/api_idp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ func Test_Get_Identity_Provider(t *testing.T) {
func Test_Activate_Identity_Provider(t *testing.T) {
createdIdp, _, err := setupIdp(randomTestString())
require.NoError(t, err, "Creating a new idp should not error")
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, createdIdp.GetStatus())
assert.Equal(t, "ACTIVE", createdIdp.GetStatus())
t.Run("deactivate idp", func(t *testing.T) {
didp, _, err := apiClient.IdentityProviderAPI.DeactivateIdentityProvider(apiClient.cfg.Context, createdIdp.GetId()).Execute()
require.NoError(t, err, "Could not deactivate idp")
assert.Equal(t, LIFECYCLESTATUS_INACTIVE, didp.GetStatus())
assert.Equal(t, "INACTIVE", didp.GetStatus())
})
t.Run("activate idp", func(t *testing.T) {
aidp, _, err := apiClient.IdentityProviderAPI.ActivateIdentityProvider(apiClient.cfg.Context, createdIdp.GetId()).Execute()
require.NoError(t, err, "Could not activate idp")
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, aidp.GetStatus())
assert.Equal(t, "ACTIVE", aidp.GetStatus())
})
err = cleanUpIdp(createdIdp.GetId())
require.NoError(t, err, "Clean up idp should not error")
Expand Down
11 changes: 6 additions & 5 deletions .generator/templates/api_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ func Test_Activate_Policy(t *testing.T) {
policy, _, err := apiClient.PolicyAPI.GetPolicy(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId()).Execute()
require.NoError(t, err, "Could not get policy by ID")
assert.Equal(t, createdPolicy.AccessPolicy.GetId(), policy.AccessPolicy.GetId())
assert.Equal(t, LIFECYCLESTATUS_INACTIVE, policy.AccessPolicy.GetStatus())
assert.Equal(t, "INACTIVE", policy.AccessPolicy.GetStatus())
})
t.Run("activate policy", func(t *testing.T) {
_, err = apiClient.PolicyAPI.ActivatePolicy(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId()).Execute()
require.NoError(t, err, "Could not activate the policy")
policy, _, err := apiClient.PolicyAPI.GetPolicy(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId()).Execute()
require.NoError(t, err, "Could not get policy by ID")
assert.Equal(t, createdPolicy.AccessPolicy.GetId(), policy.AccessPolicy.GetId())
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, policy.AccessPolicy.GetStatus())
assert.Equal(t, "ACTIVE", policy.AccessPolicy.GetStatus())
})
err = cleanUpPolicy(createdPolicy.AccessPolicy.GetId())
require.NoError(t, err, "Clean up policy should not error")
Expand All @@ -115,6 +115,7 @@ func Test_Activate_Policy(t *testing.T) {
// ACCESS/AUTHENTICATION POLICY ONLY
// TODO Used to work, now fail with 401
func Test_Clone_Policy(t *testing.T) {
t.Skip("Will failed due to change in API authz")
createdPolicy, _, err := setupAccessPolicy(randomTestString())
require.NoError(t, err, "Creating a new policy should not error")
var policyID string
Expand All @@ -141,7 +142,7 @@ func Test_Policy_Rules_Operation(t *testing.T) {
configuration.Debug = true
proxyClient := NewAPIClient(configuration)
accessPolicyRule := &AccessPolicyRule{}
accessPolicyRule.SetType(POLICYRULETYPE_ACCESS_POLICY)
accessPolicyRule.SetType("ACCESS_POLICY")
name := randomTestString()
accessPolicyRule.SetName(name)
payload := ListPolicyRules200ResponseInner{AccessPolicyRule: accessPolicyRule}
Expand Down Expand Up @@ -176,15 +177,15 @@ func Test_Policy_Rules_Operation(t *testing.T) {
require.NoError(t, err, "Could not deactivate policy rule")
rpolicyRule, _, err := apiClient.PolicyAPI.GetPolicyRule(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId()).Execute()
require.NoError(t, err, "Could not get policy rule by ID")
assert.Equal(t, LIFECYCLESTATUS_INACTIVE, rpolicyRule.AccessPolicyRule.GetStatus())
assert.Equal(t, "INACTIVE", rpolicyRule.AccessPolicyRule.GetStatus())
})

t.Run("activate policy rule", func(t *testing.T) {
_, err = apiClient.PolicyAPI.ActivatePolicyRule(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId()).Execute()
require.NoError(t, err, "Could not activate policy rule")
rpolicyRule, _, err := apiClient.PolicyAPI.GetPolicyRule(apiClient.cfg.Context, createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId()).Execute()
require.NoError(t, err, "Could not get policy rule by ID")
assert.Equal(t, LIFECYCLESTATUS_ACTIVE, rpolicyRule.AccessPolicyRule.GetStatus())
assert.Equal(t, "ACTIVE", rpolicyRule.AccessPolicyRule.GetStatus())
})
err = cleanUpPolicyRule(createdPolicy.AccessPolicy.GetId(), createdPolicyRule.AccessPolicyRule.GetId())
require.NoError(t, err, "Clean up policy rule should not error")
Expand Down
4 changes: 2 additions & 2 deletions .generator/templates/api_user_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Test_Get_User_Schema(t *testing.T) {
assert.NotEmpty(t, schema, "User schema is empty")
assert.Equal(t, "Username", schema.Definitions.Base.Properties.Login.GetTitle())
assert.Equal(t, "READ_WRITE", schema.Definitions.Base.Properties.Login.GetMutability())
assert.Equal(t, USERSCHEMAATTRIBUTESCOPE_NONE, schema.Definitions.Base.Properties.Login.GetScope())
assert.Equal(t, "NONE", schema.Definitions.Base.Properties.Login.GetScope())
assert.Equal(t, int32(5), schema.Definitions.Base.Properties.Login.GetMinLength())
assert.Equal(t, int32(100), schema.Definitions.Base.Properties.Login.GetMaxLength())
assert.NotEmpty(t, schema.Definitions.Base.Properties.Login.GetPermissions())
Expand All @@ -31,7 +31,7 @@ func Test_Update_Property_To_User_Schema(t *testing.T) {
customAttributeName := testPrefix + randomTestString()
customAttributeDetail := UserSchemaAttribute{}
customAttributeDetail.SetTitle(customAttributeName)
customAttributeDetail.SetType(USERSCHEMAATTRIBUTETYPE_STRING)
customAttributeDetail.SetType("string")
customAttributeDetail.SetMinLength(1)
customAttributeDetail.SetMaxLength(20)
customAttribute := make(map[string]UserSchemaAttribute)
Expand Down
10 changes: 5 additions & 5 deletions .generator/templates/api_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Test_Update_User_Profile(t *testing.T) {
nickName := "Batman"
t.Run("update user", func(t *testing.T) {
newProfile := user.Profile
newProfile.NickName = &nickName
newProfile.NickName = NullableString{value: &nickName, isSet: true}
req := apiClient.UserAPI.UpdateUser(apiClient.cfg.Context, user.GetId())
body := UpdateUserRequest{Profile: newProfile}
req = req.User(body)
Expand All @@ -90,7 +90,7 @@ func Test_Update_User_Profile(t *testing.T) {
t.Run("get user", func(t *testing.T) {
updatedUser, _, err := apiClient.UserAPI.GetUser(apiClient.cfg.Context, user.GetId()).Execute()
require.NoError(t, err, "Could not get user by ID")
assert.Equal(t, nickName, *updatedUser.Profile.NickName)
assert.Equal(t, nickName, updatedUser.Profile.GetNickName())
})
err = cleanUpUser(user.GetId())
require.NoError(t, err, "Clean up user should not error")
Expand Down Expand Up @@ -224,7 +224,7 @@ func Test_Assign_User_To_A_Role(t *testing.T) {
user, _, _, err := setupUser(true)
require.NoError(t, err, "Creating a new user should not error")
var roleId string
role := ROLETYPE_USER_ADMIN
role := "USER_ADMIN"
t.Run("add role to user", func(t *testing.T) {
req := apiClient.RoleAssignmentAPI.AssignRoleToUser(apiClient.cfg.Context, user.GetId())
payload := AssignRoleRequest{
Expand Down Expand Up @@ -348,9 +348,9 @@ func Test_List_User_Subscriptions(t *testing.T) {
assert.True(t, len(subscriptions) > 0, "User should have subscriptions")
})
t.Run("get user subscription by notification type", func(t *testing.T) {
subscription, _, err := apiClient.SubscriptionAPI.GetSubscriptionsNotificationTypeUser(apiClient.cfg.Context, NOTIFICATIONTYPE_OKTA_ANNOUNCEMENT, user.GetId()).Execute()
subscription, _, err := apiClient.SubscriptionAPI.GetSubscriptionsNotificationTypeUser(apiClient.cfg.Context, "OKTA_ANNOUNCEMENT", user.GetId()).Execute()
require.NoError(t, err, "Should not error getting user subscription by notification types")
assert.Equal(t, subscription.GetNotificationType(), NOTIFICATIONTYPE_OKTA_ANNOUNCEMENT, "User should have subscription notification type %q, got %q", NOTIFICATIONTYPE_OKTA_ANNOUNCEMENT, subscription.NotificationType)
assert.Equal(t, subscription.GetNotificationType(), "OKTA_ANNOUNCEMENT", "User should have subscription notification type %q, got %q", "OKTA_ANNOUNCEMENT", subscription.NotificationType)
})
}

Expand Down
20 changes: 10 additions & 10 deletions .generator/templates/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (t *TestFactory) NewValidTestRecoveryQuestionCredential() *RecoveryQuestion

func (t *TestFactory) NewValidTestIdentityProvider() *IdentityProvider {
res := IdentityProvider{}
res.SetType(IDENTITYPROVIDERTYPE_OIDC)
res.SetType("OIDC")
res.SetName(randomTestString())
res.SetProtocol(*t.NewValidTestProtocol())
res.SetPolicy(*t.NewValidTestIdentityProviderPolicy())
Expand Down Expand Up @@ -245,7 +245,7 @@ func (t *TestFactory) NewValidTestCSRMetadata() *CsrMetadata {
func (t *TestFactory) NewValidAccessPolicy(name string) *AccessPolicy {
policyRule := NewPolicyRuleConditions()
res := AccessPolicy{}
res.SetType(POLICYTYPE_ACCESS_POLICY)
res.SetType("ACCESS_POLICY")
res.SetDescription(randomTestString())
res.SetPriority(int32(1))
res.SetConditions(*policyRule)
Expand All @@ -262,7 +262,7 @@ func (t *TestFactory) NewValidBasicAuthApplication(label string) *BasicAuthAppli
res := BasicAuthApplication{}
res.SetSettings(*setting)
res.SetName("template_basic_auth")
res.SetSignOnMode(APPLICATIONSIGNONMODE_BASIC_AUTH)
res.SetSignOnMode("BASIC_AUTH")
res.SetLabel(label)
return &res
}
Expand All @@ -276,7 +276,7 @@ func (t *TestFactory) NewValidBookmarkApplication(label string) *BookmarkApplica
res := BookmarkApplication{}
res.SetSettings(*setting)
res.SetName("bookmark")
res.SetSignOnMode(APPLICATIONSIGNONMODE_BOOKMARK)
res.SetSignOnMode("BOOKMARK")
res.SetLabel(label)
return &res
}
Expand All @@ -291,7 +291,7 @@ func (t *TestFactory) NewValidOrg2OrgApplication(label string) *SamlApplication
res := SamlApplication{}
res.SetSettings(*setting)
res.SetName("okta_org2org")
res.SetSignOnMode(APPLICATIONSIGNONMODE_SAML_2_0)
res.SetSignOnMode("SAML_2_0")
res.SetLabel(label)
return &res
}
Expand All @@ -300,17 +300,17 @@ func (t *TestFactory) NewValidOIDCApplication(label string) *OpenIdConnectApplic
settingClient := NewOpenIdConnectApplicationSettingsClient()
settingClient.SetClientUri("https://example.com/client")
settingClient.SetLogoUri("https://example.com/assets/images/logo-new.png")
settingClient.SetResponseTypes([]OAuthResponseType{OAUTHRESPONSETYPE_TOKEN, OAUTHRESPONSETYPE_ID_TOKEN, OAUTHRESPONSETYPE_CODE})
settingClient.SetResponseTypes([]string{"token", "id_token", "code"})
settingClient.SetRedirectUris([]string{"https://example.com/oauth2/callback", "myapp://callback"})
settingClient.SetPostLogoutRedirectUris([]string{"https://example.com/postlogout", "myapp://postlogoutcallback"})
settingClient.SetGrantTypes([]OAuthGrantType{OAUTHGRANTTYPE_IMPLICIT, OAUTHGRANTTYPE_AUTHORIZATION_CODE})
settingClient.SetApplicationType(OPENIDCONNECTAPPLICATIONTYPE_NATIVE)
settingClient.SetGrantTypes([]string{"implicit", "authorization_code"})
settingClient.SetApplicationType("native")
settingClient.SetTosUri("https://example.com/client/tos")
settingClient.SetPolicyUri("https://example.com/client/policy")
setting := NewOpenIdConnectApplicationSettings()
setting.SetOauthClient(*settingClient)
credClient := NewApplicationCredentialsOAuthClient()
credClient.SetTokenEndpointAuthMethod(OAUTHENDPOINTAUTHENTICATIONMETHOD_CLIENT_SECRET_POST)
credClient.SetTokenEndpointAuthMethod("client_secret_post")
credClient.SetClientId(randomTestString())
credClient.SetAutoKeyRotation(true)
credentials := NewOAuthApplicationCredentials()
Expand All @@ -319,7 +319,7 @@ func (t *TestFactory) NewValidOIDCApplication(label string) *OpenIdConnectApplic
res.SetSettings(*setting)
res.SetCredentials(*credentials)
res.SetName("oidc_client")
res.SetSignOnMode(APPLICATIONSIGNONMODE_OPENID_CONNECT)
res.SetSignOnMode("OPENID_CONNECT")
res.SetLabel(label)
return &res
}
6 changes: 3 additions & 3 deletions .github/workflows/prepareReleaseBranch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
- name: Set openapi generator version
run: openapi-generator-cli version-manager set 7.0.1
- name: Generate go client
run: make v3-generate
run: make v4-generate
- run: make fmt
- run: make import
- run: cd okta/v3 && mv go.mod go.sum ../../
- run: cd okta && mv v3/* ./ && rm -rf v3
- run: cd okta/v4 && mv go.mod go.sum ../../
- run: cd okta && mv v4/* ./ && rm -rf v4
- name: Commit generated code
uses: EndBug/add-and-commit@v9
with:
Expand Down
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Okta Golang management SDK migration guide

## Migrating from 2.x to 3.x
## Migrating from 2.x to 4.x

In releases prior to version 3 we use an Open API v2 specification, and an Okta custom client generator to partially generate our SDK. A new version of the Open API specification (V3) has been released, and new well-known generators are now available and well received by the community. Planning the future of this SDK, we consider this a good opportunity to modernize by aligning with established standards for API client generation.

We acknowledge that migrating from v2 to v3 will require considerable effort, but we expect this change to benefit our customers in the long term.
We acknowledge that migrating from v2 to v4 will require considerable effort, but we expect this change to benefit our customers in the long term.

With OpenAPI v3, we saw an opportunity for improvement in several areas:

Expand Down Expand Up @@ -119,4 +119,4 @@ The following features have been ported to 6.x:
* Manual pagination for collections
* Default retry strategy for 429 HTTP responses and ability to provide your own strategy
* Web proxy
* OAuth for Okta
* OAuth for Okta
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ import: check-goimports
check-goimports:
@which $(GOIMPORTS) > /dev/null || GO111MODULE=on go install golang.org/x/tools/cmd/goimports@latest

v3-test:
go test -failfast -race ./okta/v3 -test.v
v4-test:
go test -failfast -race ./okta -test.v

v3-generate:
npx @openapitools/openapi-generator-cli generate -c ./.generator/config.yaml -i .generator/okta-management-APIs-oasv3-enum-inheritance.yaml
v4-generate:
npx @openapitools/openapi-generator-cli generate -c ./.generator/config.yaml -i .generator/okta-management-APIs-oasv3-noEnums-inheritance.yaml

0 comments on commit caf1c8d

Please sign in to comment.