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