Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 56 lines (46 sloc) 1.786 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 (
"testing"
"bytes"
)

// 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", err.Error())
}
}
}
Something went wrong with that request. Please try again.