go-plan9-auth / auth / rpc_test.go

// Copyright 2012 The go-plan9-auth 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 auth

import (

func TestGetUserPassword(t *testing.T) {
	user, pass := "gopher", "gorocks"
	params := "dom=testing.golang.org proto=pass role=client"
	key := params + fmt.Sprintf(" user=%s !password=%s", user, pass)

	ctl, err := newControl()
	if err != nil {
		t.Fatalf("open factotum/ctl: %v", err)
	defer ctl.Close()
	if err := ctl.AddKey(key); err != nil {
		t.Fatalf("AddKey failed: %v\n", err)

	user1, pass1, err := GetUserPassword(nil, params)
	if err != nil {
		t.Errorf("GetUserPassword failed: %v\n", err)
	if user1 != user || pass1 != pass {
		t.Errorf("GetUserPassword gave user=%s !password=%s; want user=%s !password=%s\n", user1, pass1, user, pass)

	if err := ctl.DeleteKey(params); err != nil {
		t.Errorf("DeleteKey failed: %v\n", err)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.