mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-03 11:08:34 +00:00
Vendor using dep
This commit is contained in:
81
vendor/github.com/google/go-github/github/admin_test.go
generated
vendored
Normal file
81
vendor/github.com/google/go-github/github/admin_test.go
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
// Copyright 2016 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package github
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAdminService_UpdateUserLDAPMapping(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
input := &UserLDAPMapping{
|
||||
LDAPDN: String("uid=asdf,ou=users,dc=github,dc=com"),
|
||||
}
|
||||
|
||||
mux.HandleFunc("/admin/ldap/users/u/mapping", func(w http.ResponseWriter, r *http.Request) {
|
||||
v := new(UserLDAPMapping)
|
||||
json.NewDecoder(r.Body).Decode(v)
|
||||
|
||||
testMethod(t, r, "PATCH")
|
||||
if !reflect.DeepEqual(v, input) {
|
||||
t.Errorf("Request body = %+v, want %+v", v, input)
|
||||
}
|
||||
fmt.Fprint(w, `{"id":1,"ldap_dn":"uid=asdf,ou=users,dc=github,dc=com"}`)
|
||||
})
|
||||
|
||||
mapping, _, err := client.Admin.UpdateUserLDAPMapping(context.Background(), "u", input)
|
||||
if err != nil {
|
||||
t.Errorf("Admin.UpdateUserLDAPMapping returned error: %v", err)
|
||||
}
|
||||
|
||||
want := &UserLDAPMapping{
|
||||
ID: Int(1),
|
||||
LDAPDN: String("uid=asdf,ou=users,dc=github,dc=com"),
|
||||
}
|
||||
if !reflect.DeepEqual(mapping, want) {
|
||||
t.Errorf("Admin.UpdateUserLDAPMapping returned %+v, want %+v", mapping, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
input := &TeamLDAPMapping{
|
||||
LDAPDN: String("cn=Enterprise Ops,ou=teams,dc=github,dc=com"),
|
||||
}
|
||||
|
||||
mux.HandleFunc("/admin/ldap/teams/1/mapping", func(w http.ResponseWriter, r *http.Request) {
|
||||
v := new(TeamLDAPMapping)
|
||||
json.NewDecoder(r.Body).Decode(v)
|
||||
|
||||
testMethod(t, r, "PATCH")
|
||||
if !reflect.DeepEqual(v, input) {
|
||||
t.Errorf("Request body = %+v, want %+v", v, input)
|
||||
}
|
||||
fmt.Fprint(w, `{"id":1,"ldap_dn":"cn=Enterprise Ops,ou=teams,dc=github,dc=com"}`)
|
||||
})
|
||||
|
||||
mapping, _, err := client.Admin.UpdateTeamLDAPMapping(context.Background(), 1, input)
|
||||
if err != nil {
|
||||
t.Errorf("Admin.UpdateTeamLDAPMapping returned error: %v", err)
|
||||
}
|
||||
|
||||
want := &TeamLDAPMapping{
|
||||
ID: Int(1),
|
||||
LDAPDN: String("cn=Enterprise Ops,ou=teams,dc=github,dc=com"),
|
||||
}
|
||||
if !reflect.DeepEqual(mapping, want) {
|
||||
t.Errorf("Admin.UpdateTeamLDAPMapping returned %+v, want %+v", mapping, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user