-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mapping via config file * use objectGUID instead of objectSID default * added test package * provided example ...ldap.schema configuration * added test coverage to ldap schema default tags * cleanup test cases * correct spaces * test invalid attribute provided * no reflection * remove external deps
- Loading branch information
Showing
2 changed files
with
117 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2018-2019 CERN | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// In applying this license, CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
package ldap | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
configreader "github.com/cs3org/reva/cmd/revad/config" | ||
) | ||
|
||
var conf = ` | ||
[schema] | ||
mail = "email" | ||
dn = "dn" | ||
` | ||
|
||
func TestUserManager(t *testing.T) { | ||
// negative test for parseConfig | ||
_, err := New(map[string]interface{}{"hostname": 42}) | ||
if err == nil { | ||
t.Fatal("expected error but got none") | ||
} | ||
|
||
r := strings.NewReader(conf) | ||
config, err := configreader.Read(r) | ||
if err != nil { | ||
t.Fatal("error reading config") | ||
} | ||
|
||
c, err := parseConfig(config) | ||
if err != nil { | ||
t.Fatal("error parsing config") | ||
} | ||
|
||
// UID not provided in config file. should not modify defaults | ||
if c.Schema.UID != ldapDefaults.UID { | ||
t.Fatalf("expected default UID to be: %v, got %v", ldapDefaults.UID, c.Schema.UID) | ||
} | ||
|
||
// DisplayName not provided in config file. should not modify defaults | ||
if c.Schema.DisplayName != ldapDefaults.DisplayName { | ||
t.Fatalf("expected DisplayName to be: %v, got %v", ldapDefaults.DisplayName, c.Schema.DisplayName) | ||
} | ||
|
||
// Mail provided in config file | ||
if c.Schema.Mail != "email" { | ||
t.Fatalf("expected default UID to be: %v, got %v", "email", c.Schema.Mail) | ||
} | ||
|
||
// DN provided in config file | ||
if c.Schema.DN != ldapDefaults.DN { | ||
t.Fatalf("expected DisplayName to be: %v, got %v", ldapDefaults.DN, c.Schema.DN) | ||
} | ||
|
||
// possitive tests for New | ||
_, err = New(config) | ||
if err != nil { | ||
t.Fatalf(err.Error()) | ||
} | ||
} |