| 36 | } |
| 37 | |
| 38 | func TestBasicUserAPI(t *testing.T) { |
| 39 | for i, tc := range basicUserTests { |
| 40 | req := baseReq() |
| 41 | req.Header.Set("X-AppEngine-User-Nickname", tc.nickname) |
| 42 | req.Header.Set("X-AppEngine-User-Email", tc.email) |
| 43 | req.Header.Set("X-AppEngine-Auth-Domain", tc.authDomain) |
| 44 | req.Header.Set("X-AppEngine-User-Is-Admin", tc.admin) |
| 45 | |
| 46 | c := internal.ContextForTesting(req) |
| 47 | |
| 48 | if ga := IsAdmin(c); ga != tc.isAdmin { |
| 49 | t.Errorf("test %d: expected IsAdmin(c) = %v, got %v", i, tc.isAdmin, ga) |
| 50 | } |
| 51 | |
| 52 | u := Current(c) |
| 53 | if tc.isNil { |
| 54 | if u != nil { |
| 55 | t.Errorf("test %d: expected u == nil, got %+v", i, u) |
| 56 | } |
| 57 | continue |
| 58 | } |
| 59 | if u == nil { |
| 60 | t.Errorf("test %d: expected u != nil, got nil", i) |
| 61 | continue |
| 62 | } |
| 63 | if u.Email != tc.email { |
| 64 | t.Errorf("test %d: expected u.Email = %q, got %q", i, tc.email, u.Email) |
| 65 | } |
| 66 | if gs := u.String(); gs != tc.displayName { |
| 67 | t.Errorf("test %d: expected u.String() = %q, got %q", i, tc.displayName, gs) |
| 68 | } |
| 69 | if u.Admin != tc.isAdmin { |
| 70 | t.Errorf("test %d: expected u.Admin = %v, got %v", i, tc.isAdmin, u.Admin) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | func TestLoginURL(t *testing.T) { |
| 76 | expectedQuery := &pb.CreateLoginURLRequest{ |