Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 55 lines (46 sloc) 1.79 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
// Copyright 2010 Florian Duraffourg. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package openid

import (
"bytes"
"testing"
)

// normalizeIdentifier Test

type normalizeIdentifierTest struct {
in, out string
t int
}

var normalizeIdentifierTests = []normalizeIdentifierTest{
//normalizeIdentifierTest{"example.com", "http://example.com/", identifierURL},
//normalizeIdentifierTest{"http://example.com", "http://example.com/", identifierURL},
normalizeIdentifierTest{"https://example.com/", "https://example.com/", identifierURL},
normalizeIdentifierTest{"http://example.com/user", "http://example.com/user", identifierURL},
normalizeIdentifierTest{"http://example.com/user/", "http://example.com/user/", identifierURL},
normalizeIdentifierTest{"http://example.com/", "http://example.com/", identifierURL},
normalizeIdentifierTest{"=example", "=example", identifierXRI},
normalizeIdentifierTest{"xri://=example", "=example", identifierXRI},
}

func TestnormalizeIdentifier(testing *testing.T) {
for _, nit := range normalizeIdentifierTests {
v, t := normalizeIdentifier(nit.in)
if !bytes.Equal([]byte(v), []byte(nit.out)) || t != nit.t {
testing.Errorf("normalizeIdentifier(%s) = (%s, %d) want (%s, %d).", nit.in, v, t, nit.out, nit.t)
}
}
}

// GetRedirectURL Test

var Identifiers = []string{
"https://www.google.com/accounts/o8/id",
//"orange.fr",
//"yahoo.com",
}

// Just check that there is no errors returned by GetRedirectURL
func TestGetRedirectURL(t *testing.T) {
for _, url := range Identifiers {
_, err := GetRedirectURL(url, "http://example.com", "/loginCheck")
if err != nil {
t.Errorf("GetRedirectURL() returned the error: %s\n", err.Error())
}
}
}
Something went wrong with that request. Please try again.