Browse Source

Fix issue with pointers

master
harture 7 years ago
parent
commit
d726826888
  1. 12
      authentication_management.go
  2. 10
      integration/integration.go
  3. 10
      keycloak_client.go
  4. 4
      realm.go
  5. 4
      users.go

12
authentication_management.go

@ -49,8 +49,8 @@ func (c *Client) DeleteAuthenticatorConfig(accessToken string, realmName, config
// CreateAuthenticationExecution add new authentication execution
func (c *Client) CreateAuthenticationExecution(accessToken string, realmName string, authExec AuthenticationExecutionRepresentation) (string, error) {
var location *string
return *location, c.post(accessToken, nil, location, url.Path(authenticationManagementPath+"/executions"), url.Param("realm", realmName), body.JSON(authExec))
var location string
return location, c.post(accessToken, nil, &location, url.Path(authenticationManagementPath+"/executions"), url.Param("realm", realmName), body.JSON(authExec))
}
// DeleteAuthenticationExecution deletes the execution.
@ -109,16 +109,16 @@ func (c *Client) UpdateAuthenticationExecutionForFlow(accessToken string, realmN
// 'flowAlias' is the alias of the parent flow.
func (c *Client) CreateAuthenticationExecutionForFlow(accessToken string, realmName, flowAlias, provider string) (string, error) {
var m = map[string]string{"provider": provider}
var location *string
return *location, c.post(accessToken, nil, location, url.Path(authenticationManagementPath+"/flows/:flowAlias/executions/execution"), url.Param("realm", realmName), url.Param("flowAlias", flowAlias), body.JSON(m))
var location string
return location, c.post(accessToken, nil, &location, url.Path(authenticationManagementPath+"/flows/:flowAlias/executions/execution"), url.Param("realm", realmName), url.Param("flowAlias", flowAlias), body.JSON(m))
}
// CreateFlowWithExecutionForExistingFlow add a new flow with a new execution to an existing flow.
// 'flowAlias' is the alias of the parent authentication flow.
func (c *Client) CreateFlowWithExecutionForExistingFlow(accessToken string, realmName, flowAlias, alias, flowType, provider, description string) (string, error) {
var m = map[string]string{"alias": alias, "type": flowType, "provider": provider, "description": description}
var location *string
return *location, c.post(accessToken, nil, location, url.Path(authenticationManagementPath+"/flows/:flowAlias/executions/flow"), url.Param("realm", realmName), url.Param("flowAlias", flowAlias), body.JSON(m))
var location string
return location, c.post(accessToken, nil, &location, url.Path(authenticationManagementPath+"/flows/:flowAlias/executions/flow"), url.Param("realm", realmName), url.Param("flowAlias", flowAlias), body.JSON(m))
}
// GetAuthenticationFlow gets the authentication flow for id.

10
integration/integration.go

@ -49,7 +49,8 @@ func main() {
// Create test realm.
{
var realm = tstRealm
var err = client.CreateRealm(accessToken, keycloak.RealmRepresentation{
var err error
_, err = client.CreateRealm(accessToken, keycloak.RealmRepresentation{
Realm: &realm,
})
if err != nil {
@ -111,7 +112,8 @@ func main() {
for _, u := range tstUsers {
var username = strings.ToLower(u.firstname + "." + u.lastname)
var email = username + "@cloudtrust.ch"
var err = client.CreateUser(accessToken, tstRealm, keycloak.UserRepresentation{
var err error
_, err = client.CreateUser(accessToken, tstRealm, keycloak.UserRepresentation{
Username: &username,
FirstName: &u.firstname,
LastName: &u.lastname,
@ -341,8 +343,8 @@ func getKeycloakConfig() *keycloak.Config {
pflag.Parse()
return &keycloak.Config{
Addr: *adr,
Timeout: 10 * time.Second,
Addr: *adr,
Timeout: 10 * time.Second,
}
}

10
keycloak_client.go

@ -131,9 +131,9 @@ func (c *Client) get(accessToken string, data interface{}, plugins ...plugin.Plu
switch {
case resp.StatusCode == http.StatusUnauthorized:
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, resp.String())
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 400:
return fmt.Errorf("invalid status code: '%v': %v", resp.RawResponse.Status, resp.String())
return fmt.Errorf("invalid status code: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 200:
switch resp.Header.Get("Content-Type") {
case "application/json":
@ -163,7 +163,7 @@ func (c *Client) post(accessToken string, data interface{}, location *string, pl
switch {
case resp.StatusCode == http.StatusUnauthorized:
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, resp.String())
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 400:
return fmt.Errorf("invalid status code: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 200:
@ -199,7 +199,7 @@ func (c *Client) delete(accessToken string, plugins ...plugin.Plugin) error {
switch {
case resp.StatusCode == http.StatusUnauthorized:
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, resp.String())
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 400:
return fmt.Errorf("invalid status code: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 200:
@ -224,7 +224,7 @@ func (c *Client) put(accessToken string, plugins ...plugin.Plugin) error {
switch {
case resp.StatusCode == http.StatusUnauthorized:
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, resp.String())
return fmt.Errorf("unauthorized request: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 400:
return fmt.Errorf("invalid status code: '%v': %v", resp.RawResponse.Status, string(resp.Bytes()))
case resp.StatusCode >= 200:

4
realm.go

@ -21,8 +21,8 @@ func (c *Client) GetRealms(accessToken string) ([]RealmRepresentation, error){
// CreateRealm creates the realm from its RealmRepresentation.
func (c *Client) CreateRealm(accessToken string, realm RealmRepresentation) (string, error) {
var location *string
return *location, c.post(accessToken, nil, location, url.Path(realmRootPath), body.JSON(realm))
var location string
return location, c.post(accessToken, nil, &location, url.Path(realmRootPath), body.JSON(realm))
}
// GetRealm get the top level represention of the realm. Nested information like users are

4
users.go

@ -30,8 +30,8 @@ func (c *Client) GetUsers(accessToken string, realmName string, paramKV ...strin
// CreateUser creates the user from its UserRepresentation. The username must be unique.
func (c *Client) CreateUser(accessToken string, realmName string, user UserRepresentation) (string, error) {
var location *string
return *location, c.post(accessToken, nil, location, url.Path(userPath), url.Param("realm", realmName), body.JSON(user))
var location string
return location, c.post(accessToken, nil, &location, url.Path(userPath), url.Param("realm", realmName), body.JSON(user))
}
// CountUsers returns the number of users in the realm.

Loading…
Cancel
Save