workerschema: move Client.Revoke to RefreshClient

also, RevokeClient -> RevokeClient for consistency.
This commit is contained in:
Bobby Rullo 2016-04-26 12:05:41 -07:00
parent e1c070d84e
commit 2406c09598
5 changed files with 137 additions and 138 deletions

View file

@ -382,10 +382,9 @@ func TestCreateClient(t *testing.T) {
return u return u
} }
addIDAndSecret := func(cliNum int, hostport string, cli adminschema.Client) *adminschema.Client { addIDAndSecret := func(cli adminschema.Client) *adminschema.Client {
cli.Id = fmt.Sprintf("client_%v.example.com", hostport) cli.Id = "client_auth.example.com"
cli.Secret = base64.URLEncoding.EncodeToString([]byte( cli.Secret = base64.URLEncoding.EncodeToString([]byte("client_0"))
fmt.Sprintf("client_%d", cliNum)))
return &cli return &cli
} }
@ -448,7 +447,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminClientGood, Client: &adminClientGood,
}, },
want: adminschema.ClientCreateResponse{ want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminClientGood), Client: addIDAndSecret(adminClientGood),
}, },
wantClient: clientGood, wantClient: clientGood,
}, },
@ -457,7 +456,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminAdminClient, Client: &adminAdminClient,
}, },
want: adminschema.ClientCreateResponse{ want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminAdminClient), Client: addIDAndSecret(adminAdminClient),
}, },
wantClient: clientGoodAdmin, wantClient: clientGoodAdmin,
}, },
@ -466,7 +465,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminMultiRedirect, Client: &adminMultiRedirect,
}, },
want: adminschema.ClientCreateResponse{ want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminMultiRedirect), Client: addIDAndSecret(adminMultiRedirect),
}, },
wantClient: clientMultiRedirect, wantClient: clientMultiRedirect,
}, },
@ -475,7 +474,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminClientWithPeers, Client: &adminClientWithPeers,
}, },
want: adminschema.ClientCreateResponse{ want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminClientWithPeers), Client: addIDAndSecret(adminClientWithPeers),
}, },
wantClient: clientGood, wantClient: clientGood,
wantTrustedPeers: []string{"test_client_0"}, wantTrustedPeers: []string{"test_client_0"},

View file

@ -199,7 +199,7 @@ A client with associated public metadata.
> __Description__ > __Description__
> List all clients that hold refresh tokens for the authenticated user. > List all clients that hold refresh tokens for the specified user.
> __Parameters__ > __Parameters__
@ -221,11 +221,11 @@ A client with associated public metadata.
> __Summary__ > __Summary__
> Revoke Clients > Revoke RefreshClient
> __Description__ > __Description__
> Revoke all refresh tokens issues to the client for the authenticated user. > Revoke all refresh tokens issues to the client for the specified user.
> __Parameters__ > __Parameters__

View file

@ -334,82 +334,7 @@ func (c *ClientsListCall) Do() (*ClientPage, error) {
} }
// method id "dex.Client.Revoke": // method id "dex.RefreshClient.List":
type ClientsRevokeCall struct {
s *Service
userid string
clientid string
opt_ map[string]interface{}
}
// Revoke: Revoke all refresh tokens issues to the client for the
// authenticated user.
func (r *ClientsService) Revoke(userid string, clientid string) *ClientsRevokeCall {
c := &ClientsRevokeCall{s: r.s, opt_: make(map[string]interface{})}
c.userid = userid
c.clientid = clientid
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *ClientsRevokeCall) Fields(s ...googleapi.Field) *ClientsRevokeCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *ClientsRevokeCall) Do() error {
var body io.Reader = nil
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "account/{userid}/refresh/{clientid}")
urls += "?" + params.Encode()
req, _ := http.NewRequest("DELETE", urls, body)
googleapi.Expand(req.URL, map[string]string{
"userid": c.userid,
"clientid": c.clientid,
})
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return err
}
return nil
// {
// "description": "Revoke all refresh tokens issues to the client for the authenticated user.",
// "httpMethod": "DELETE",
// "id": "dex.Client.Revoke",
// "parameterOrder": [
// "userid",
// "clientid"
// ],
// "parameters": {
// "clientid": {
// "location": "path",
// "required": true,
// "type": "string"
// },
// "userid": {
// "location": "path",
// "required": true,
// "type": "string"
// }
// },
// "path": "account/{userid}/refresh/{clientid}"
// }
}
// method id "dex.Client.List":
type RefreshClientListCall struct { type RefreshClientListCall struct {
s *Service s *Service
@ -417,7 +342,7 @@ type RefreshClientListCall struct {
opt_ map[string]interface{} opt_ map[string]interface{}
} }
// List: List all clients that hold refresh tokens for the authenticated // List: List all clients that hold refresh tokens for the specified
// user. // user.
func (r *RefreshClientService) List(userid string) *RefreshClientListCall { func (r *RefreshClientService) List(userid string) *RefreshClientListCall {
c := &RefreshClientListCall{s: r.s, opt_: make(map[string]interface{})} c := &RefreshClientListCall{s: r.s, opt_: make(map[string]interface{})}
@ -461,9 +386,9 @@ func (c *RefreshClientListCall) Do() (*RefreshClientList, error) {
} }
return ret, nil return ret, nil
// { // {
// "description": "List all clients that hold refresh tokens for the authenticated user.", // "description": "List all clients that hold refresh tokens for the specified user.",
// "httpMethod": "GET", // "httpMethod": "GET",
// "id": "dex.Client.List", // "id": "dex.RefreshClient.List",
// "parameterOrder": [ // "parameterOrder": [
// "userid" // "userid"
// ], // ],
@ -482,6 +407,81 @@ func (c *RefreshClientListCall) Do() (*RefreshClientList, error) {
} }
// method id "dex.RefreshClient.Revoke":
type RefreshClientRevokeCall struct {
s *Service
userid string
clientid string
opt_ map[string]interface{}
}
// Revoke: Revoke all refresh tokens issues to the client for the
// specified user.
func (r *RefreshClientService) Revoke(userid string, clientid string) *RefreshClientRevokeCall {
c := &RefreshClientRevokeCall{s: r.s, opt_: make(map[string]interface{})}
c.userid = userid
c.clientid = clientid
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *RefreshClientRevokeCall) Fields(s ...googleapi.Field) *RefreshClientRevokeCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *RefreshClientRevokeCall) Do() error {
var body io.Reader = nil
params := make(url.Values)
params.Set("alt", "json")
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "account/{userid}/refresh/{clientid}")
urls += "?" + params.Encode()
req, _ := http.NewRequest("DELETE", urls, body)
googleapi.Expand(req.URL, map[string]string{
"userid": c.userid,
"clientid": c.clientid,
})
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return err
}
return nil
// {
// "description": "Revoke all refresh tokens issues to the client for the specified user.",
// "httpMethod": "DELETE",
// "id": "dex.RefreshClient.Revoke",
// "parameterOrder": [
// "userid",
// "clientid"
// ],
// "parameters": {
// "clientid": {
// "location": "path",
// "required": true,
// "type": "string"
// },
// "userid": {
// "location": "path",
// "required": true,
// "type": "string"
// }
// },
// "path": "account/{userid}/refresh/{clientid}"
// }
}
// method id "dex.User.Create": // method id "dex.User.Create":
type UsersCreateCall struct { type UsersCreateCall struct {

View file

@ -272,28 +272,6 @@ const DiscoveryJSON = `{
"response": { "response": {
"$ref": "ClientWithSecret" "$ref": "ClientWithSecret"
} }
},
"Revoke": {
"id": "dex.Client.Revoke",
"description": "Revoke all refresh tokens issues to the client for the authenticated user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
} }
} }
}, },
@ -398,8 +376,8 @@ const DiscoveryJSON = `{
"RefreshClient": { "RefreshClient": {
"methods": { "methods": {
"List": { "List": {
"id": "dex.Client.List", "id": "dex.RefreshClient.List",
"description": "List all clients that hold refresh tokens for the authenticated user.", "description": "List all clients that hold refresh tokens for the specified user.",
"httpMethod": "GET", "httpMethod": "GET",
"path": "account/{userid}/refresh", "path": "account/{userid}/refresh",
"parameters": { "parameters": {
@ -415,6 +393,28 @@ const DiscoveryJSON = `{
"response": { "response": {
"$ref": "RefreshClientList" "$ref": "RefreshClientList"
} }
},
"Revoke": {
"id": "dex.RefreshClient.Revoke",
"description": "Revoke all refresh tokens issues to the client for the specified user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
} }
} }
} }

View file

@ -266,28 +266,6 @@
"response": { "response": {
"$ref": "ClientWithSecret" "$ref": "ClientWithSecret"
} }
},
"Revoke": {
"id": "dex.Client.Revoke",
"description": "Revoke all refresh tokens issues to the client for the authenticated user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
} }
} }
}, },
@ -392,8 +370,8 @@
"RefreshClient": { "RefreshClient": {
"methods": { "methods": {
"List": { "List": {
"id": "dex.Client.List", "id": "dex.RefreshClient.List",
"description": "List all clients that hold refresh tokens for the authenticated user.", "description": "List all clients that hold refresh tokens for the specified user.",
"httpMethod": "GET", "httpMethod": "GET",
"path": "account/{userid}/refresh", "path": "account/{userid}/refresh",
"parameters": { "parameters": {
@ -409,6 +387,28 @@
"response": { "response": {
"$ref": "RefreshClientList" "$ref": "RefreshClientList"
} }
},
"Revoke": {
"id": "dex.RefreshClient.Revoke",
"description": "Revoke all refresh tokens issues to the client for the specified user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
} }
} }
} }