Skip to content

Commit

Permalink
depth 2
Browse files Browse the repository at this point in the history
  • Loading branch information
maastha committed Dec 17, 2024
1 parent 5cdb685 commit 5931a2f
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 149 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/autoupdate-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '2'
- name: Temp check Git SHA after checkout depth 3
run: |
git rev-parse HEAD
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
Expand All @@ -23,8 +28,8 @@ jobs:
git config --global user.name "github-actions[bot]"
git add .
git commit --allow-empty -m "fix: update OpenAPI spec"
- name: Set old commit for SDK API diff
run: echo "API_DIFF_OLD_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
# - name: Set old commit for SDK API diff
# run: echo "API_DIFF_OLD_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Run generation
working-directory: ./tools
run: |
Expand Down
13 changes: 7 additions & 6 deletions admin/api_alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,18 @@ type AcknowledgeAlertApiRequest struct {
}

type AcknowledgeAlertApiParams struct {
GroupId string
AlertId string
GroupId string
// AlertId string
AlertIdTemp string
AcknowledgeAlert *AcknowledgeAlert
}

func (a *AlertsApiService) AcknowledgeAlertWithParams(ctx context.Context, args *AcknowledgeAlertApiParams) AcknowledgeAlertApiRequest {
return AcknowledgeAlertApiRequest{
ApiService: a,
ctx: ctx,
groupId: args.GroupId,
alertId: args.AlertId,
ApiService: a,
ctx: ctx,
groupId: args.GroupId,
// alertId: args.AlertId,
acknowledgeAlert: args.AcknowledgeAlert,
}
}
Expand Down
11 changes: 6 additions & 5 deletions admin/api_atlas_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ type AtlasSearchApi interface {
type AtlasSearchApiService service

type CreateAtlasSearchDeploymentApiRequest struct {
ctx context.Context
ApiService AtlasSearchApi
ctx context.Context
// ApiService AtlasSearchApi
groupId string
clusterName string
apiSearchDeploymentRequest *ApiSearchDeploymentRequest
Expand All @@ -510,7 +510,7 @@ type CreateAtlasSearchDeploymentApiParams struct {

func (a *AtlasSearchApiService) CreateAtlasSearchDeploymentWithParams(ctx context.Context, args *CreateAtlasSearchDeploymentApiParams) CreateAtlasSearchDeploymentApiRequest {
return CreateAtlasSearchDeploymentApiRequest{
ApiService: a,
// ApiService: a,
ctx: ctx,
groupId: args.GroupId,
clusterName: args.ClusterName,
Expand All @@ -519,7 +519,8 @@ func (a *AtlasSearchApiService) CreateAtlasSearchDeploymentWithParams(ctx contex
}

func (r CreateAtlasSearchDeploymentApiRequest) Execute() (*ApiSearchDeploymentResponse, *http.Response, error) {
return r.ApiService.CreateAtlasSearchDeploymentExecute(r)
// return r.ApiService.CreateAtlasSearchDeploymentExecute(r)

Check failure on line 522 in admin/api_atlas_search.go

View workflow job for this annotation

GitHub Actions / code-health

commentedOutCode: may want to remove commented-out code (gocritic)
return nil, nil, nil
}

/*
Expand All @@ -534,7 +535,7 @@ Creates Search Nodes for the specified cluster.
*/
func (a *AtlasSearchApiService) CreateAtlasSearchDeployment(ctx context.Context, groupId string, clusterName string, apiSearchDeploymentRequest *ApiSearchDeploymentRequest) CreateAtlasSearchDeploymentApiRequest {
return CreateAtlasSearchDeploymentApiRequest{
ApiService: a,
// ApiService: a,
ctx: ctx,
groupId: groupId,
clusterName: clusterName,
Expand Down
4 changes: 2 additions & 2 deletions auth/code/device_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type DeviceCode struct {
VerificationURI string `json:"verification_uri"` // VerificationURI is the URI where users will need to confirm the code
DeviceCode string `json:"device_code"` // DeviceCode is the internal code to confirm the status of the flow
ExpiresIn int `json:"expires_in"` // ExpiresIn when the code will expire
Interval int `json:"interval"` // Interval how often to verify the status of the code
// Interval int `json:"interval"` // Interval how often to verify the status of the code

timeNow func() time.Time
timeSleep func(time.Duration)
Expand Down Expand Up @@ -95,7 +95,7 @@ func (c Config) PollToken(ctx context.Context, code *DeviceCode) (*Token, *core.
timeSleep = time.Sleep
}

checkInterval := time.Duration(code.Interval) * time.Second
checkInterval := time.Duration(60) * time.Second
expiresAt := timeNow().Add(time.Duration(code.ExpiresIn) * time.Second)

for {
Expand Down
218 changes: 109 additions & 109 deletions auth/code/device_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,77 +22,77 @@ import (
"github.com/go-test/deep"
)

func TestConfig_RequestCode(t *testing.T) {
config, mux, teardown := setup()
defer teardown()

mux.HandleFunc("/api/private/unauth/account/device/authorize", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r)
fmt.Fprintf(w, `{
"user_code": "QW3PYV7R",
"verification_uri": "%s/account/connect",
"device_code": "61eef18e310968047ff5e02a",
"expires_in": 600,
"interval": 10
}`, baseURLPath)
})

results, _, err := config.RequestCode(ctx)
if err != nil {
t.Fatalf("RequestCode returned error: %v", err)
}

expected := &DeviceCode{
UserCode: "QW3PYV7R",
VerificationURI: baseURLPath + "/account/connect",
DeviceCode: "61eef18e310968047ff5e02a",
ExpiresIn: 600,
Interval: 10,
}

if diff := deep.Equal(results, expected); diff != nil {
t.Error(diff)
}
}

func TestConfig_GetToken(t *testing.T) {
config, mux, teardown := setup()
defer teardown()

mux.HandleFunc("/api/private/unauth/account/device/token", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r)
fmt.Fprint(w, `{
"access_token": "secret1",
"refresh_token": "secret2",
"scope": "openid",
"id_token": "idtoken",
"token_type": "Bearer",
"expires_in": 3600
}`)
})
code := &DeviceCode{
DeviceCode: "61eef18e310968047ff5e02a",
ExpiresIn: 600,
Interval: 10,
}
results, _, err := config.GetToken(ctx, code.DeviceCode)
if err != nil {
t.Fatalf("GetToken returned error: %v", err)
}

expected := &Token{
AccessToken: "secret1",
RefreshToken: "secret2",
Scope: "openid",
IDToken: "idtoken",
TokenType: "Bearer",
ExpiresIn: 3600,
}

if diff := deep.Equal(results, expected); diff != nil {
t.Error(diff)
}
}
// func TestConfig_RequestCode(t *testing.T) {
// config, mux, teardown := setup()
// defer teardown()

// mux.HandleFunc("/api/private/unauth/account/device/authorize", func(w http.ResponseWriter, r *http.Request) {
// testMethod(t, r)
// fmt.Fprintf(w, `{
// "user_code": "QW3PYV7R",
// "verification_uri": "%s/account/connect",
// "device_code": "61eef18e310968047ff5e02a",
// "expires_in": 600,
// "interval": 10
// }`, baseURLPath)
// })

// results, _, err := config.RequestCode(ctx)
// if err != nil {
// t.Fatalf("RequestCode returned error: %v", err)
// }

// expected := &DeviceCode{
// UserCode: "QW3PYV7R",
// VerificationURI: baseURLPath + "/account/connect",
// DeviceCode: "61eef18e310968047ff5e02a",
// ExpiresIn: 600,
// Interval: 10,
// }

// if diff := deep.Equal(results, expected); diff != nil {
// t.Error(diff)
// }
// }

// func TestConfig_GetToken(t *testing.T) {
// config, mux, teardown := setup()
// defer teardown()

// mux.HandleFunc("/api/private/unauth/account/device/token", func(w http.ResponseWriter, r *http.Request) {
// testMethod(t, r)
// fmt.Fprint(w, `{
// "access_token": "secret1",
// "refresh_token": "secret2",
// "scope": "openid",
// "id_token": "idtoken",
// "token_type": "Bearer",
// "expires_in": 3600
// }`)
// })
// code := &DeviceCode{
// DeviceCode: "61eef18e310968047ff5e02a",
// ExpiresIn: 600,
// Interval: 10,
// }
// results, _, err := config.GetToken(ctx, code.DeviceCode)
// if err != nil {
// t.Fatalf("GetToken returned error: %v", err)
// }

// expected := &Token{
// AccessToken: "secret1",
// RefreshToken: "secret2",
// Scope: "openid",
// IDToken: "idtoken",
// TokenType: "Bearer",
// ExpiresIn: 3600,
// }

// if diff := deep.Equal(results, expected); diff != nil {
// t.Error(diff)
// }
// }

func TestConfig_RefreshToken(t *testing.T) {
config, mux, teardown := setup()
Expand Down Expand Up @@ -129,44 +129,44 @@ func TestConfig_RefreshToken(t *testing.T) {
}
}

func TestConfig_PollToken(t *testing.T) {
config, mux, teardown := setup()
defer teardown()

mux.HandleFunc("/api/private/unauth/account/device/token", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r)
fmt.Fprint(w, `{
"access_token": "secret1",
"refresh_token": "secret2",
"scope": "openid",
"id_token": "idtoken",
"token_type": "Bearer",
"expires_in": 3600
}`)
})
code := &DeviceCode{
DeviceCode: "61eef18e310968047ff5e02a",
ExpiresIn: 600,
Interval: 10,
}
results, _, err := config.PollToken(ctx, code)
if err != nil {
t.Fatalf("PollToken returned error: %v", err)
}

expected := &Token{
AccessToken: "secret1",
RefreshToken: "secret2",
Scope: "openid",
IDToken: "idtoken",
TokenType: "Bearer",
ExpiresIn: 3600,
}

if diff := deep.Equal(results, expected); diff != nil {
t.Error(diff)
}
}
// func TestConfig_PollToken(t *testing.T) {
// config, mux, teardown := setup()
// defer teardown()

// mux.HandleFunc("/api/private/unauth/account/device/token", func(w http.ResponseWriter, r *http.Request) {
// testMethod(t, r)
// fmt.Fprint(w, `{
// "access_token": "secret1",
// "refresh_token": "secret2",
// "scope": "openid",
// "id_token": "idtoken",
// "token_type": "Bearer",
// "expires_in": 3600
// }`)
// })
// code := &DeviceCode{
// DeviceCode: "61eef18e310968047ff5e02a",
// ExpiresIn: 600,
// Interval: 10,
// }
// results, _, err := config.PollToken(ctx, code)
// if err != nil {
// t.Fatalf("PollToken returned error: %v", err)
// }

// expected := &Token{
// AccessToken: "secret1",
// RefreshToken: "secret2",
// Scope: "openid",
// IDToken: "idtoken",
// TokenType: "Bearer",
// ExpiresIn: 3600,
// }

// if diff := deep.Equal(results, expected); diff != nil {
// t.Error(diff)
// }
// }

func TestConfig_RevokeToken(t *testing.T) {
config, mux, teardown := setup()
Expand Down
1 change: 1 addition & 0 deletions internal/core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type ErrorResponse struct {
Reason string `json:"reason"`
// Detail is more detailed description of the error.
Detail string `json:"detail,omitempty"`
Temp string `json:"temp,omitempty"`
}

func (r *ErrorResponse) Error() string {
Expand Down
11 changes: 5 additions & 6 deletions mockadmin/teams_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5931a2f

Please sign in to comment.